diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index 7e8d4be..5ffe5e6 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -5,7 +5,7 @@ define([ 'base/js/namespace', 'jquery', 'codemirror/lib/codemirror', - 'components/rsvp/rsvp.min', + 'rsvp', ], function(IPython, $, CodeMirror, rsvp){ "use strict"; diff --git a/IPython/html/static/services/kernels/comm.js b/IPython/html/static/services/kernels/comm.js index c9a0635..1e74b44 100644 --- a/IPython/html/static/services/kernels/comm.js +++ b/IPython/html/static/services/kernels/comm.js @@ -5,7 +5,7 @@ define([ 'base/js/namespace', 'jquery', 'base/js/utils', - 'components/rsvp/rsvp.min', + 'rsvp', ], function(IPython, $, utils, rsvp) { "use strict"; @@ -78,8 +78,9 @@ define([ } catch (e) { comm.close(); that.unregister_comm(comm); - var error = new utils.WrappedError("Exception opening new comm", e); - return rsvp.Promise.reject(error); + var wrapped_error = new utils.WrappedError("Exception opening new comm", e); + console.error(wrapped_error); + return rsvp.Promise.reject(wrapped_error); } return comm; }, utils.reject('Could not open comm', true)); diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js index cf0e94b..7f3f70e 100644 --- a/IPython/html/static/widgets/js/manager.js +++ b/IPython/html/static/widgets/js/manager.js @@ -7,7 +7,7 @@ define([ "jquery", "base/js/utils", "base/js/namespace", - 'components/rsvp/rsvp.min', + 'rsvp', ], function (_, Backbone, $, utils, IPython, rsvp) { "use strict"; //-------------------------------------------------------------------- @@ -49,8 +49,9 @@ define([ //-------------------------------------------------------------------- WidgetManager.prototype.display_view = function(msg, model) { // Displays a view for a particular model. + var that = this; return new rsvp.Promise(function(resolve, reject) { - var cell = this.get_msg_cell(msg.parent_header.msg_id); + var cell = that.get_msg_cell(msg.parent_header.msg_id); if (cell === null) { reject(new Error("Could not determine where the display" + " message was from. Widget will not be displayed")); @@ -61,8 +62,7 @@ define([ cell.widget_subarea.append(dummy); } - var that = this; - this.create_view(model, {cell: cell}).then(function(view) { + that.create_view(model, {cell: cell}).then(function(view) { that._handle_display_view(view); if (dummy) { dummy.replaceWith(view.$el); @@ -74,8 +74,6 @@ define([ }); } }); - - }; WidgetManager.prototype._handle_display_view = function (view) { @@ -174,7 +172,7 @@ define([ }; WidgetManager.prototype.get_model = function (model_id) { - return that._models[model_id]; + return this._models[model_id]; }; WidgetManager.prototype._handle_comm_open = function (comm, msg) { @@ -182,7 +180,7 @@ define([ this.create_model({ model_name: msg.content.data.model_name, model_module: msg.content.data.model_module, - comm: comm}).handle($.proxy(console.error, error)); + comm: comm}).catch($.proxy(console.error, console)); }; 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 b45d434..e6019c5 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -7,7 +7,7 @@ define(["widgets/js/manager", "jquery", "base/js/utils", "base/js/namespace", - "components/rsvp/rsvp.min", + "rsvp", ], function(widgetmanager, _, Backbone, $, utils, IPython, rsvp){ var WidgetModel = Backbone.Model.extend({ @@ -75,15 +75,21 @@ define(["widgets/js/manager", case 'update': this.state_change = this.state_change.then(function() { return that.set_state(msg.content.data.state); - }); + }).catch(utils.reject({ + message: "Couldn't process update msg", + model_id: that.id + }, true)); break; case 'custom': this.trigger('msg:custom', msg.content.data.content); break; case 'display': this.state_change = this.state_change.then(function () { - that.widget_manager.display_view(msg, that); - }); + return that.widget_manager.display_view(msg, that); + }).catch(utils.reject({ + message: "Couldn't process display msg", + model_id: that.id + }, true)); break; } }, diff --git a/IPython/html/templates/page.html b/IPython/html/templates/page.html index 93ba4b5..28d3005 100644 --- a/IPython/html/templates/page.html +++ b/IPython/html/templates/page.html @@ -31,6 +31,7 @@ codemirror: 'components/codemirror', termjs: "components/term.js/src/term", contents: '{{ contents_js_source }}', + rsvp: "components/rsvp/rsvp", }, shim: { underscore: {