mirror of
https://github.com/zadam/trilium.git
synced 2025-12-13 02:44:24 +01: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 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") {
|
if ([400, 404].includes(statusCode) && response && typeof response === "object") {
|
||||||
toastService.showError(messageStr);
|
toastService.showError(messageStr);
|
||||||
@ -274,10 +274,13 @@ async function reportError(method: string, url: string, statusCode: number, resp
|
|||||||
...response
|
...response
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const title = `${statusCode} ${method} ${url}`;
|
const { t } = await import("./i18n.js");
|
||||||
toastService.showErrorTitleAndMessage(title, messageStr);
|
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");
|
const { throwError } = await import("./ws.js");
|
||||||
throwError(`${title} - ${message}`);
|
throwError(`${statusCode} ${method} ${url} - ${message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2107,5 +2107,9 @@
|
|||||||
},
|
},
|
||||||
"popup-editor": {
|
"popup-editor": {
|
||||||
"maximize": "Switch to full 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