Show More
@@ -70,23 +70,21 b' define([' | |||||
70 |
|
70 | |||
71 | this.comms[comm_id] = utils.load_class(content.target_name, content.target_module, |
|
71 | this.comms[comm_id] = utils.load_class(content.target_name, content.target_module, | |
72 | this.targets).then(function(target) { |
|
72 | this.targets).then(function(target) { | |
73 |
|
73 | var comm = new Comm(content.target_name, comm_id); | ||
74 | var comm = new Comm(content.target_name, comm_id); |
|
74 | comm.kernel = that.kernel; | |
75 | comm.kernel = that.kernel; |
|
75 | try { | |
76 | try { |
|
76 | var response = target(comm, msg); | |
77 | var response = target(comm, msg); |
|
77 | } catch (e) { | |
78 | if (response instanceof Promise) { |
|
78 | comm.close(); | |
79 | return response.then(function() { return Promise.resolve(comm); }); |
|
79 | that.unregister_comm(comm); | |
|
80 | var wrapped_error = new utils.WrappedError("Exception opening new comm", e); | |||
|
81 | console.error(wrapped_error); | |||
|
82 | return Promise.reject(wrapped_error); | |||
80 | } |
|
83 | } | |
81 | } catch (e) { |
|
84 | // Regardless of the target return value, we need to | |
82 | comm.close(); |
|
85 | // then return the comm | |
83 | that.unregister_comm(comm); |
|
86 | return Promise.resolve(response).then(function() {return comm;}); | |
84 | var wrapped_error = new utils.WrappedError("Exception opening new comm", e); |
|
87 | }, utils.reject('Could not open comm', true)); | |
85 | console.error(wrapped_error); |
|
|||
86 | return Promise.reject(wrapped_error); |
|
|||
87 | } |
|
|||
88 | return Promise.resolve(comm); |
|
|||
89 | }, utils.reject('Could not open comm', true)); |
|
|||
90 | return this.comms[comm_id]; |
|
88 | return this.comms[comm_id]; | |
91 | }; |
|
89 | }; | |
92 |
|
90 | |||
@@ -104,6 +102,8 b' define([' | |||||
104 | } catch (e) { |
|
102 | } catch (e) { | |
105 | console.log("Exception closing comm: ", e, e.stack, msg); |
|
103 | console.log("Exception closing comm: ", e, e.stack, msg); | |
106 | } |
|
104 | } | |
|
105 | // don't return a comm, so that further .then() functions | |||
|
106 | // get an undefined comm input | |||
107 | }); |
|
107 | }); | |
108 | }; |
|
108 | }; | |
109 |
|
109 | |||
@@ -120,7 +120,7 b' define([' | |||||
120 | } catch (e) { |
|
120 | } catch (e) { | |
121 | console.log("Exception handling comm msg: ", e, e.stack, msg); |
|
121 | console.log("Exception handling comm msg: ", e, e.stack, msg); | |
122 | } |
|
122 | } | |
123 |
return |
|
123 | return comm; | |
124 | }); |
|
124 | }); | |
125 | }; |
|
125 | }; | |
126 |
|
126 |
@@ -49,24 +49,24 b' define([' | |||||
49 | WidgetManager.prototype.display_view = function(msg, model) { |
|
49 | WidgetManager.prototype.display_view = function(msg, model) { | |
50 | // Displays a view for a particular model. |
|
50 | // Displays a view for a particular model. | |
51 | var that = this; |
|
51 | var that = this; | |
52 | return new Promise(function(resolve, reject) { |
|
52 | var cell = this.get_msg_cell(msg.parent_header.msg_id); | |
53 | var cell = that.get_msg_cell(msg.parent_header.msg_id); |
|
53 | if (cell === null) { | |
54 | if (cell === null) { |
|
54 | return Promise.reject(new Error("Could not determine where the display" + | |
55 | reject(new Error("Could not determine where the display" + |
|
55 | " message was from. Widget will not be displayed")); | |
56 | " message was from. Widget will not be displayed")); |
|
56 | } else if (cell.widget_subarea) { | |
57 | } else if (cell.widget_subarea) { |
|
57 | var dummy = $('<div />'); | |
58 | var dummy = $('<div />'); |
|
58 | cell.widget_subarea.append(dummy); | |
59 | cell.widget_subarea.append(dummy); |
|
59 | return this.create_view(model, {cell: cell}).then( | |
60 | that.create_view(model, {cell: cell}).then(function(view) { |
|
60 | function(view) { | |
61 | that._handle_display_view(view); |
|
61 | that._handle_display_view(view); | |
62 | dummy.replaceWith(view.$el); |
|
62 | dummy.replaceWith(view.$el); | |
63 | view.trigger('displayed'); |
|
63 | view.trigger('displayed'); | |
64 |
re |
|
64 | return view; | |
65 |
}, |
|
65 | }, | |
66 | reject(new utils.WrappedError('Could not display view', error)); |
|
66 | function(error) { | |
|
67 | return Promise.reject(new utils.WrappedError('Could not display view', error)); | |||
67 | }); |
|
68 | }); | |
68 |
|
|
69 | } | |
69 | }); |
|
|||
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | WidgetManager.prototype._handle_display_view = function (view) { |
|
72 | WidgetManager.prototype._handle_display_view = function (view) { |
@@ -95,7 +95,6 b' define(["widgets/js/manager",' | |||||
95 | } finally { |
|
95 | } finally { | |
96 | that.state_lock = null; |
|
96 | that.state_lock = null; | |
97 | } |
|
97 | } | |
98 | return Promise.resolve(); |
|
|||
99 | }, utils.reject("Couldn't set model state", true)); |
|
98 | }, utils.reject("Couldn't set model state", true)); | |
100 | }, |
|
99 | }, | |
101 |
|
100 |
General Comments 0
You need to be logged in to leave comments.
Login now