Skip to content

Commit

Permalink
fix: Update error logging to use error name as title and improve stac…
Browse files Browse the repository at this point in the history
…k trace parsing in index.ts
  • Loading branch information
austenstone committed Nov 26, 2024
1 parent 2c63b66 commit 6486069
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ try {
} catch (e) {
if (e instanceof Error) {
const stack = e.stack?.split("\n").map((s) => {
const path = s.split("/");
const _file = path[path.length - 1];
const [file, startLine, startColumn] = _file.split(":");
const [file, startLine, startColumn] = s.split(":");
return {
file,
startLine: Number(startLine),
startColumn: Number(startColumn),
startLine: parseInt(startLine),
startColumn: parseInt(startColumn),
};
});
info(`Stack: ${JSON.stringify(stack, null, 2)}`);
error(e.message, {
title: e.message,
title: e.name,
...(stack ? stack[stack.length - 1] : {}),
});
}
Expand Down

0 comments on commit 6486069

Please sign in to comment.