Skip to content

Commit 806f93b

Browse files
committed
Merge pull request phaserjs#2251 from milkey-mouse/fix-404-success
Fix issue phaserjs#2250: Loader.binary returns success on 404
2 parents 0b8fc6e + d1c4297 commit 806f93b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/loader/Loader.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,9 +2308,12 @@ Phaser.Loader.prototype = {
23082308
xhr.onload = function () {
23092309

23102310
try {
2311-
2312-
return onload.call(_this, file, xhr);
2313-
2311+
if (xhr.readyState == 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
2312+
return onerror.call(_this, file, xhr);
2313+
}
2314+
else {
2315+
return onload.call(_this, file, xhr);
2316+
}
23142317
} catch (e) {
23152318

23162319
// If this was the last file in the queue and an error is thrown in the create method
@@ -2419,6 +2422,12 @@ Phaser.Loader.prototype = {
24192422

24202423
xhr.onload = function () {
24212424
try {
2425+
if (xhr.readyState == 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
2426+
return onerror.call(_this, file, xhr);
2427+
}
2428+
else {
2429+
return onload.call(_this, file, xhr);
2430+
}
24222431
return onload.call(_this, file, xhr);
24232432
} catch (e) {
24242433
_this.asyncComplete(file, e.message || 'Exception');

0 commit comments

Comments
 (0)