From 230def10fea9fe43dbe4309e880a24a443d2b4f6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 6 Dec 2025 22:12:06 +0200 Subject: [PATCH] feat(client): improve error message for HTTP errors --- apps/client/src/services/server.ts | 11 +++++++---- apps/client/src/translations/en/translation.json | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/client/src/services/server.ts b/apps/client/src/services/server.ts index b2e6efb9a..eb5d01382 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, resp const 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.json index 5e2934f34..c6f9beaad 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}}" } }