From d1c42978022b34823a9e01b9bcfb27e2f5b8e482 Mon Sep 17 00:00:00 2001 From: Milkey Mouse Date: Wed, 9 Dec 2015 19:54:48 -0800 Subject: [PATCH] Fix #2250 changes by @mhstar89 --- src/loader/Loader.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/loader/Loader.js b/src/loader/Loader.js index b83f752ee..87f073722 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -2308,9 +2308,12 @@ Phaser.Loader.prototype = { xhr.onload = function () { try { - - return onload.call(_this, file, xhr); - + 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. + return onerror.call(_this, file, xhr); + } + else { + return onload.call(_this, file, xhr); + } } catch (e) { // 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 = { xhr.onload = function () { try { + 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. + return onerror.call(_this, file, xhr); + } + else { + return onload.call(_this, file, xhr); + } return onload.call(_this, file, xhr); } catch (e) { _this.asyncComplete(file, e.message || 'Exception');