From da253012c7d1f6185a3e01115159820226287f03 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Mon, 26 Dec 2016 19:40:33 +0100 Subject: [PATCH] During load from json send error to reviver (#3586) * send error to reviver * add error to imageFromObject --- src/shapes/image.class.js | 6 +++++- src/util/misc.js | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 902827f7276..25093787f20 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -628,7 +628,11 @@ * @param {Function} callback Callback to invoke when an image instance is created */ fabric.Image.fromObject = function(object, callback) { - fabric.util.loadImage(object.src, function(img) { + fabric.util.loadImage(object.src, function(img, error) { + if (error) { + callback && callback(null, error); + return; + } fabric.Image.prototype._initFilters.call(object, object.filters, function(filters) { object.filters = filters || []; fabric.Image.prototype._initFilters.call(object, object.resizeFilters, function(resizeFilters) { diff --git a/src/util/misc.js b/src/util/misc.js index 7b74fc69676..78a3b378f81 100644 --- a/src/util/misc.js +++ b/src/util/misc.js @@ -328,10 +328,8 @@ var klass = fabric.util.getKlass(o.type, namespace); if (klass.async) { klass.fromObject(o, function (obj, error) { - if (!error) { - enlivenedObjects[index] = obj; - reviver && reviver(o, enlivenedObjects[index]); - } + enlivenedObjects[index] = obj; + reviver && reviver(o, enlivenedObjects[index], error); onLoaded(); }); }