mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-10 03:53:37 -06:00
feat(client): improve error message for HTTP errors
This commit is contained in:
parent
036f8e49a4
commit
230def10fe
@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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}}"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user