diff --git a/widgetsnbextension/src/extension.js b/widgetsnbextension/src/extension.js index e8b09b59895..03c1d7afcb2 100644 --- a/widgetsnbextension/src/extension.js +++ b/widgetsnbextension/src/extension.js @@ -123,15 +123,12 @@ function register_events(Jupyter, events, outputarea) { Jupyter.notebook.kernel && Jupyter.notebook.kernel.widget_manager; if (!manager) { - node.textContent = - 'Error rendering Jupyter widget: missing widget manager'; - return; + throw new Error('Error rendering Jupyter widget: missing widget manager'); } // Missing model id means the view was removed. Hide this element. if (data.model_id === '') { - node.style.display = 'none'; - return; + throw new Error('Jupyter Widgets model not found'); } var model = manager.get_model(data.model_id); @@ -156,8 +153,9 @@ function register_events(Jupyter, events, outputarea) { }); }); } else { - node.textContent = - 'A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.'; + throw new Error( + 'A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells.' + ); } } @@ -169,6 +167,7 @@ function register_events(Jupyter, events, outputarea) { element.append(toinsert); return toinsert; }; + // Register mime type with the output area outputarea.OutputArea.prototype.register_mime_type(MIME_TYPE, append_mime, { // An output widget could contain arbitrary user javascript