mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 16:37:58 +01:00
Improved json load error messages
This commit is contained in:
parent
3fb8323103
commit
3c2b73794a
@ -15,20 +15,20 @@ function jsonRequest(address, callback) {
|
|||||||
callback(json, null)
|
callback(json, null)
|
||||||
}, 0);
|
}, 0);
|
||||||
} else if (this.status === 404 || this.status === 403 || this.status === 500) {
|
} else if (this.status === 404 || this.status === 403 || this.status === 500) {
|
||||||
callback(null, this.status)
|
callback(null, "HTTP " + this.status + " (See " + address + ")")
|
||||||
} else if (this.status === 400) {
|
} else if (this.status === 400) {
|
||||||
callback(null, this.responseText)
|
callback(null, this.responseText + " (See " + address + ")")
|
||||||
} else if (this.status === 0) {
|
} else if (this.status === 0) {
|
||||||
callback(null, "Request was blocked. (Adblocker maybe?)")
|
callback(null, "Request was blocked. (Adblocker maybe?)")
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callback(null, e.message)
|
callback(null, e.message + " (See " + address + ")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhttp.timeout = 20000;
|
xhttp.timeout = 20000;
|
||||||
xhttp.ontimeout = function () {
|
xhttp.ontimeout = function () {
|
||||||
callback(null, "Timed out after 20 seconds.")
|
callback(null, "Timed out after 20 seconds. (" + address + ")")
|
||||||
};
|
};
|
||||||
xhttp.open("GET", address, true);
|
xhttp.open("GET", address, true);
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
|
Loading…
Reference in New Issue
Block a user