Attempt to improve error logging

This commit is contained in:
Akim Mamedov 2023-12-18 22:27:41 +07:00
parent fd23160f81
commit 61964ccb1e
2 changed files with 17 additions and 2 deletions

View File

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

View File

@ -110,5 +110,11 @@ btn.addEventListener("click", () => {
inner.id = "res";
inner.innerText = res;
document.getElementById("res-placeholder").appendChild(inner);
}).catch(console.log);
}).catch(err => {
if (err instanceof Error) {
console.log({ name: err.name, message: err.message, stack: err.stack });
return;
}
console.log(err);
});
});