mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-24 04:54:51 -04:00
Give more info when a ZIM file is not found in unit tests.
Now it gives an error in the console log. Fixes #234 Also replace this.* by xhr.* to be consistent in the code style
This commit is contained in:
parent
165ae7a8bd
commit
3a166b8ed4
@ -36,22 +36,26 @@ define(['jquery', 'zimArchive', 'zimDirEntry', 'util', 'utf8'],
|
||||
return new Promise(function (resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url);
|
||||
xhr.onload = function () {
|
||||
if ((this.status >= 200 && this.status < 300) || xhr.status == 0 ) {
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0 ) {
|
||||
var blob = new Blob([xhr.response], {type: 'application/octet-stream'});
|
||||
blob.name = name;
|
||||
resolve(blob);
|
||||
}else
|
||||
{
|
||||
}
|
||||
else {
|
||||
console.error("Error reading file " + url + " status:" + xhr.status + ", statusText:" + xhr.statusText);
|
||||
reject({
|
||||
status: this.status,
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
console.error("Error reading file " + url + " status:" + xhr.status + ", statusText:" + xhr.statusText);
|
||||
reject({
|
||||
status: this.status,
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user