mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-19 18:21:37 +08:00
client: Strengthen widget rendering errors detection
This commit is contained in:
parent
eee088316d
commit
cb4fe4481f
@ -86,32 +86,7 @@ class BasicWidget extends Component {
|
|||||||
try {
|
try {
|
||||||
this.doRender();
|
this.doRender();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Got issue in widget ", this);
|
this.logRenderingError(e);
|
||||||
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
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$widget.attr('data-component-id', this.componentId);
|
this.$widget.attr('data-component-id', this.componentId);
|
||||||
@ -150,6 +125,35 @@ class BasicWidget extends Component {
|
|||||||
return this.$widget;
|
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.
|
* 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
|
* @returns
|
||||||
|
@ -8,7 +8,11 @@ export default class Container extends BasicWidget {
|
|||||||
|
|
||||||
renderChildren() {
|
renderChildren() {
|
||||||
for (const widget of this.children) {
|
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