JSON stringify errors

This commit is contained in:
Akim Mamedov 2023-12-18 22:36:36 +07:00
parent 61964ccb1e
commit 57f8a851eb
2 changed files with 10 additions and 8 deletions

View File

@ -13,13 +13,15 @@ function App() {
}) })
.catch((err) => { .catch((err) => {
if (err instanceof Error) { if (err instanceof Error) {
console.log({ console.log(
JSON.stringify({
name: err.name, name: err.name,
message: err.message, message: err.message,
stack: err.stack, stack: err.stack,
}); }),
);
} else { } else {
console.log(err); console.log(JSON.stringify(err));
} }
setResult({ type: "failure", error: err.toString() }); setResult({ type: "failure", error: err.toString() });

View File

@ -112,9 +112,9 @@ btn.addEventListener("click", () => {
document.getElementById("res-placeholder").appendChild(inner); document.getElementById("res-placeholder").appendChild(inner);
}).catch(err => { }).catch(err => {
if (err instanceof Error) { if (err instanceof Error) {
console.log({ name: err.name, message: err.message, stack: err.stack }); console.log(JSON.stringify({ name: err.name, message: err.message, stack: err.stack }));
return; return;
} }
console.log(err); console.log(JSON.stringify(err));
}); });
}); });