Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 0ba9fc7

Browse files
committed
client: Display errors for right panel widgets instead of crashing
1 parent 584ba24 commit 0ba9fc7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/public/app/widgets/right_panel_widget.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import NoteContextAwareWidget from "./note_context_aware_widget.js";
2+
import toastService from "../services/toast.js";
3+
import { t } from "../services/i18n.js";
24

35
const WIDGET_TPL = `
46
<div class="card widget">
@@ -54,7 +56,19 @@ class RightPanelWidget extends NoteContextAwareWidget {
5456
this.$buttons.append(buttonWidget.render());
5557
}
5658

57-
this.initialized = this.doRenderBody();
59+
try {
60+
this.initialized = this.doRenderBody();
61+
} catch (e) {
62+
toastService.showPersistent({
63+
title: t("toast.widget-error.title"),
64+
icon: "alert",
65+
message: t("toast.widget-error.message", {
66+
title: this.widgetTitle,
67+
message: e.message
68+
})
69+
});
70+
logError(e);
71+
}
5872
}
5973

6074
/**

src/public/translations/en/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"critical-error": {
1414
"title": "Critical error",
1515
"message": "A critical error has occurred which prevents the client application from starting:\n\n{{message}}\n\nThis is most likely caused by a script failing in an unexpected way. Try starting the application in safe mode and addressing the issue."
16+
},
17+
"widget-error": {
18+
"title": "Failed to initialize a widget",
19+
"message": "Widget with title \"{{title}}\" could not be initialized due to:\n\n{{message}}"
1620
}
1721
}
1822
}

0 commit comments

Comments
 (0)