mirror of
https://github.com/zadam/trilium.git
synced 2026-01-01 20:24:25 +01:00
feat(script): improve script error message
This commit is contained in:
parent
8fda283977
commit
19cd7a0cad
@ -46,17 +46,7 @@ export async function executeBundle(bundle: Bundle, originEntity?: Entity | null
|
||||
return eval(`const apiContext = this; (async function() { ${bundle.script}\r\n})()`);
|
||||
}.call(apiContext);
|
||||
} catch (e: any) {
|
||||
const note = await froca.getNote(bundle.noteId);
|
||||
toastService.showPersistent({
|
||||
id: `custom-script-failure-${note?.noteId}`,
|
||||
title: t("toast.bundle-error.title"),
|
||||
icon: "bx bx-error-circle",
|
||||
message: t("toast.bundle-error.message", {
|
||||
id: note?.noteId,
|
||||
title: note?.title,
|
||||
message: e.message
|
||||
})
|
||||
});
|
||||
showErrorForScriptNote(bundle.noteId, t("toast.bundle-error.message", { message: e.message }));
|
||||
logError("Widget initialization failed: ", e);
|
||||
}
|
||||
}
|
||||
@ -151,17 +141,7 @@ async function getWidgetBundlesByParent() {
|
||||
}
|
||||
} catch (e: any) {
|
||||
const noteId = bundle.noteId;
|
||||
const note = await froca.getNote(noteId);
|
||||
toastService.showPersistent({
|
||||
id: `custom-script-failure-${noteId}`,
|
||||
title: t("toast.bundle-error.title"),
|
||||
icon: "bx bx-error-circle",
|
||||
message: t("toast.bundle-error.message", {
|
||||
id: noteId,
|
||||
title: note?.title,
|
||||
message: e.message
|
||||
})
|
||||
});
|
||||
showErrorForScriptNote(noteId, t("toast.bundle-error.message", { message: e.message }));
|
||||
|
||||
logError("Widget initialization failed: ", e);
|
||||
continue;
|
||||
|
||||
@ -69,7 +69,7 @@ export async function showErrorForScriptNote(noteId: string, message: string) {
|
||||
|
||||
showPersistent({
|
||||
id: `custom-widget-failure-${noteId}`,
|
||||
title: note?.title ?? "",
|
||||
title: t("toast.scripting-error", { title: note?.title ?? "" }),
|
||||
icon: note?.getIcon() ?? "bx bx-error-circle",
|
||||
message,
|
||||
timeout: 15_000,
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
},
|
||||
"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}}"
|
||||
"message": "Script could not be executed due to:\n\n{{message}}"
|
||||
},
|
||||
"widget-list-error": {
|
||||
"title": "Failed to obtain the list of widgets from the server"
|
||||
@ -30,7 +30,8 @@
|
||||
"title": "Failed to render a custom React widget"
|
||||
},
|
||||
"widget-missing-parent": "Custom widget does not have mandatory '{{property}}' property defined.",
|
||||
"open-script-note": "Open script note"
|
||||
"open-script-note": "Open script note",
|
||||
"scripting-error": "Custom script error: {{title}}"
|
||||
},
|
||||
"add_link": {
|
||||
"add_link": "Add link",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user