diff --git a/src/public/app/widgets/basic_widget.js b/src/public/app/widgets/basic_widget.js index 7c7c08c1a..4dd580bd2 100644 --- a/src/public/app/widgets/basic_widget.js +++ b/src/public/app/widgets/basic_widget.js @@ -85,33 +85,8 @@ class BasicWidget extends Component { render() { try { this.doRender(); - } catch (e) { - console.log("Got issue in widget ", this); - console.error(e); - - let noteId = this._noteId; - if (this._noteId) { - froca.getNote(noteId, true).then((note) => { - toastService.showPersistent({ - title: t("toast.widget-error.title"), - icon: "alert", - message: t("toast.widget-error.message-custom", { - id: noteId, - title: note.title, - message: e.message - }) - }); - }); - return; - } - - toastService.showPersistent({ - title: t("toast.widget-error.title"), - icon: "alert", - message: t("toast.widget-error.message-unknown", { - message: e.message - }) - }); + } catch (e) { + this.logRenderingError(e); } this.$widget.attr('data-component-id', this.componentId); @@ -150,6 +125,35 @@ class BasicWidget extends Component { return this.$widget; } + logRenderingError(e) { + console.log("Got issue in widget ", this); + console.error(e); + + let noteId = this._noteId; + if (this._noteId) { + froca.getNote(noteId, true).then((note) => { + toastService.showPersistent({ + title: t("toast.widget-error.title"), + icon: "alert", + message: t("toast.widget-error.message-custom", { + id: noteId, + title: note.title, + message: e.message + }) + }); + }); + return; + } + + toastService.showPersistent({ + title: t("toast.widget-error.title"), + icon: "alert", + message: t("toast.widget-error.message-unknown", { + message: e.message + }) + }); + } + /** * Indicates if the widget is enabled. Widgets are enabled by default. Generally setting this to `false` will cause the widget not to be displayed, however it will still be available on the DOM but hidden. * @returns diff --git a/src/public/app/widgets/containers/container.js b/src/public/app/widgets/containers/container.js index ba47a8db0..07c759bb0 100644 --- a/src/public/app/widgets/containers/container.js +++ b/src/public/app/widgets/containers/container.js @@ -8,7 +8,11 @@ export default class Container extends BasicWidget { renderChildren() { for (const widget of this.children) { - this.$widget.append(widget.render()); + try { + this.$widget.append(widget.render()); + } catch (e) { + widget.logRenderingError(e); + } } } }