From e6a8ef00e006a0b599112f2d809a28c573bb1003 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Tue, 25 Nov 2014 23:08:06 +0000 Subject: [PATCH] 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. --- IPython/html/static/widgets/js/manager.js | 6 +++--- IPython/html/static/widgets/js/widget.js | 4 ++-- IPython/html/static/widgets/js/widget_box.js | 2 +- IPython/html/static/widgets/js/widget_selectioncontainer.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js index 1087426af..e7ee68653 100644 --- a/IPython/html/static/widgets/js/manager.js +++ b/IPython/html/static/widgets/js/manager.js @@ -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) { diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index d7bac7623..e8e63a5ec 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -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(){ diff --git a/IPython/html/static/widgets/js/widget_box.js b/IPython/html/static/widgets/js/widget_box.js index a8c6fd8c6..ef473579c 100644 --- a/IPython/html/static/widgets/js/widget_box.js +++ b/IPython/html/static/widgets/js/widget_box.js @@ -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() { diff --git a/IPython/html/static/widgets/js/widget_selectioncontainer.js b/IPython/html/static/widgets/js/widget_selectioncontainer.js index 516a8d9d3..c146e1db9 100644 --- a/IPython/html/static/widgets/js/widget_selectioncontainer.js +++ b/IPython/html/static/widgets/js/widget_selectioncontainer.js @@ -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) {