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
feat(client): improve error message for HTTP errors
Elian Doran230def10fea9
diff --git a/apps/client/src/services/server.ts b/apps/client/src/services/server.tsindex b2e6efb9a4..eb5d013824 100644--- a/apps/client/src/services/server.ts+++ b/apps/client/src/services/server.ts@@ -263,7 +263,7 @@ async function reportError(method: string, url: string, statusCode: number, respconst toastService = (await import("./toast.js")).default;- const messageStr = typeof message === "string" ? message : JSON.stringify(message);+ const messageStr = (typeof message === "string" ? message : JSON.stringify(message)) || "-";if ([400, 404].includes(statusCode) && response && typeof response === "object") {toastService.showError(messageStr);@@ -274,10 +274,13 @@ async function reportError(method: string, url: string, statusCode: number, resp...response});} else {- const title = `${statusCode} ${method} ${url}`;- toastService.showErrorTitleAndMessage(title, messageStr);+ const { t } = await import("./i18n.js");+ toastService.showErrorTitleAndMessage(+ t("server.unknown_http_error_title"),+ t("server.unknown_http_error_content", { statusCode, method, url, message: messageStr }),+ 15_000);const { throwError } = await import("./ws.js");- throwError(`${title} - ${message}`);+ throwError(`${statusCode} ${method} ${url} - ${message}`);}}diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5e2934f349..c6f9beaad3 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2107,5 +2107,9 @@},"popup-editor": {"maximize": "Switch to full editor"+ },+ "server": {+ "unknown_http_error_title": "Communication error with the server",+ "unknown_http_error_content": "Status code: {{statusCode}}\nURL: {{method}} {{url}}\nMessage: {{message}}"}}