Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client: Improve logging for some bundle errors
Elian Doraneee088316dee
diff --git a/src/public/app/desktop.js b/src/public/app/desktop.jsindex febb9a8f93..835624d359 100644--- a/src/public/app/desktop.js+++ b/src/public/app/desktop.js@@ -9,9 +9,9 @@ import electronContextMenu from "./menus/electron_context_menu.js";import glob from "./services/glob.js";import { t } from "./services/i18n.js";+await appContext.earlyInit();+bundleService.getWidgetBundlesByParent().then(async widgetBundles => {- await appContext.earlyInit();-// A dynamic import is required for layouts since they initialize components which require translations.const DesktopLayout = (await import("./layouts/desktop_layout.js")).default;diff --git a/src/public/app/services/bundle.js b/src/public/app/services/bundle.jsindex 72636e7e51..279d2d560d 100644--- a/src/public/app/services/bundle.js+++ b/src/public/app/services/bundle.js@@ -3,6 +3,7 @@ import server from "./server.js";import toastService from "./toast.js";import froca from "./froca.js";import utils from "./utils.js";+import { t } from "./i18n.js";async function getAndExecuteBundle(noteId, originEntity = null, script = null, params = null) {const bundle = await server.post(`script/bundle/${noteId}`, {@@ -79,6 +80,18 @@ async function getWidgetBundlesByParent() {widgetsByParent.add(widget);}catch (e) {+ const noteId = bundle.noteId;+ const note = await froca.getNote(noteId);+ toastService.showPersistent({+ title: t("toast.bundle-error.title"),+ icon: "alert",+ message: t("toast.bundle-error.message", {+ id: noteId,+ title: note.title,+ message: e.message+ })+ });+logError("Widget initialization failed: ", e);continue;}diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.jsonindex 40891d3333..984867d07a 100644--- a/src/public/translations/en/translation.json+++ b/src/public/translations/en/translation.json@@ -18,6 +18,10 @@"title": "Failed to initialize a widget","message-custom": "Custom widget from note with ID \"{{id}}\", titled \"{{title}}\" could not be initialized due to:\n\n{{message}}","message-unknown": "Unknown widget could not be initialized due to:\n\n{{message}}"+ },+ "bundle-error": {+ "title": "Failed to load a custom script",+ "message": "Script from note with ID \"{{id}}\", titled \"{{title}}\" could not be executed due to:\n\n{{message}}"}},"add_link": {