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) => {
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,
}),
);
} else {
console.log(err);
console.log(JSON.stringify(err));
}
setResult({ type: "failure", error: err.toString() });

View File

@ -112,9 +112,9 @@ btn.addEventListener("click", () => {
document.getElementById("res-placeholder").appendChild(inner);
}).catch(err => {
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;
}
console.log(err);
console.log(JSON.stringify(err));
});
});