mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-18 17:31:53 +08:00
client: Strengthen widget rendering errors detection
This commit is contained in:
parent
eee088316d
commit
cb4fe4481f
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user