Catch errors after our then()s, instead of in parallel with them (this missing exceptions)

When an error is thrown in a then() success handler, it doesn't call the same then()'s error handler.

I also made all of the utils.reject handlers verbose to aid in debugging.
This commit is contained in:
Jason Grout 2014-11-25 23:08:06 +00:00
parent efe7098a60
commit e6a8ef00e0
4 changed files with 8 additions and 8 deletions

View File

@ -62,7 +62,7 @@ define([
dummy.replaceWith(view.$el);
view.trigger('displayed');
return view;
}, utils.reject('Could not display view'));
}).catch(utils.reject('Could not display view', true));
}
};
@ -103,7 +103,7 @@ define([
view.listenTo(model, 'destroy', view.remove);
view.render();
return view;
}, utils.reject("Couldn't create a view for model id '" + String(model.id) + "'"));
}).catch(utils.reject("Couldn't create a view for model id '" + String(model.id) + "'", true));
});
return model.state_change;
};
@ -178,7 +178,7 @@ define([
return this.create_model({
model_name: msg.content.data.model_name,
model_module: msg.content.data.model_module,
comm: comm}).catch(utils.reject("Couldn't create a model."));
comm: comm}).catch(utils.reject("Couldn't create a model.", true));
};
WidgetManager.prototype.create_model = function (options) {

View File

@ -95,7 +95,7 @@ define(["widgets/js/manager",
} finally {
that.state_lock = null;
}
}, utils.reject("Couldn't set model state", true));
}).catch(utils.reject("Couldn't set model state", true));
},
_handle_status: function (msg, callbacks) {
@ -309,7 +309,7 @@ define(["widgets/js/manager",
// Create and promise that resolves to a child view of a given model
var that = this;
options = $.extend({ parent: this }, options || {});
return this.model.widget_manager.create_view(child_model, options).catch(utils.reject("Couldn't create child view"));
return this.model.widget_manager.create_view(child_model, options).catch(utils.reject("Couldn't create child view"), true);
},
callbacks: function(){

View File

@ -75,7 +75,7 @@ define([
view.trigger('displayed');
});
return view;
}, utils.reject("Couldn't add child view to box", true));
}).catch(utils.reject("Couldn't add child view to box", true));
},
remove: function() {

View File

@ -125,7 +125,7 @@ define([
view.trigger('displayed');
});
return view;
}, utils.reject("Couldn't add child view to box", true));
}).catch(utils.reject("Couldn't add child view to box", true));
},
remove: function() {
@ -220,7 +220,7 @@ define([
view.trigger('displayed');
});
return view;
}, utils.reject("Couldn't add child view to box", true));
}).catch(utils.reject("Couldn't add child view to box", true));
},
update: function(options) {