mirror of
https://github.com/zadam/trilium.git
synced 2025-10-04 20:47:40 +08:00
chore(client): fix logging errors with circular objects
This commit is contained in:
parent
10abb50971
commit
b379f89a7a
1 changed files with 7 additions and 1 deletions
|
@ -26,12 +26,18 @@ function setupGlobs() {
|
|||
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
||||
const string = String(msg).toLowerCase();
|
||||
|
||||
let errorObjectString = "";
|
||||
try {
|
||||
errorObjectString = JSON.stringify(error);
|
||||
} catch (e: any) {
|
||||
errorObjectString = e.toString();
|
||||
}
|
||||
let message = "Uncaught error: ";
|
||||
|
||||
if (string.includes("script error")) {
|
||||
message += "No details available";
|
||||
} else {
|
||||
message += [`Message: ${msg}`, `URL: ${url}`, `Line: ${lineNo}`, `Column: ${columnNo}`, `Error object: ${JSON.stringify(error)}`, `Stack: ${error && error.stack}`].join(", ");
|
||||
message += [`Message: ${msg}`, `URL: ${url}`, `Line: ${lineNo}`, `Column: ${columnNo}`, `Error object: ${errorObjectString}`, `Stack: ${error && error.stack}`].join(", ");
|
||||
}
|
||||
|
||||
ws.logError(message);
|
||||
|
|
Loading…
Add table
Reference in a new issue