Skip to content

Commit

Permalink
fix: Refine error logging by simplifying stack trace extraction and i…
Browse files Browse the repository at this point in the history
…mproving file path formatting in index.ts and index.js
  • Loading branch information
austenstone committed Nov 26, 2024
1 parent 6a3bedd commit fe9e2b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
23 changes: 12 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29154,23 +29154,24 @@ try {
}
catch (e) {
if (e instanceof Error) {
const stack = e.stack?.split("\n").map((s) => {
const [file, startLine, startColumn] = s.split(":");
return {
file,
startLine: parseInt(startLine),
startColumn: parseInt(startColumn),
};
});
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Stack: ${JSON.stringify(stack, null, 2)}`);
const lastStackEntry = e.stack?.split("\n").pop()?.split(":");
const stackInfo = lastStackEntry
? {
file: lastStackEntry[0],
startLine: parseInt(lastStackEntry[1]),
startColumn: parseInt(lastStackEntry[2]),
}
: {};
stackInfo.file?.replace(`/home/runner/work/${_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.owner}/${_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo.repo}/`, "");
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.info)(`Stack: ${JSON.stringify(stackInfo, null, 2)}`);
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.error)(e.message, {
title: e.name,
...(stack ? stack[stack.length - 1] : {}),
...stackInfo,
});
}
throw e;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9DOi9Vc2Vycy9hdXN0ZS9zb3VyY2UvYWN0aW9uLXR5cGVzY3JpcHQvc3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsSUFBSSxFQUFFLEtBQUssRUFBRSxLQUFLLEVBQUU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LEVBQUUsQ0FBQyxDQUFDLElBQUk7WUFDYixHQUFHLFNBQVM7U0FDYixDQUFDLENBQUM7SUFDTCxDQUFDO0lBQ0QsTUFBTSxDQUFDLENBQUM7QUFDVixDQUFDIn0=
__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@ try {
});
} catch (e) {
if (e instanceof Error) {
const stack = e.stack?.split("\n").map((s) => {
const [file, startLine, startColumn] = s.split(":");
return {
file,
startLine: parseInt(startLine),
startColumn: parseInt(startColumn),
};
});
info(`Stack: ${JSON.stringify(stack, null, 2)}`);
const lastStackEntry = e.stack?.split("\n").pop()?.split(":");
const stackInfo = lastStackEntry
? {
file: lastStackEntry[0],
startLine: parseInt(lastStackEntry[1]),
startColumn: parseInt(lastStackEntry[2]),
}
: {};

stackInfo.file?.replace(
`/home/runner/work/${context.repo.owner}/${context.repo.repo}/`,
"",
);
info(`Stack: ${JSON.stringify(stackInfo, null, 2)}`);
error(e.message, {
title: e.name,
...(stack ? stack[stack.length - 1] : {}),
...stackInfo,
});
}
throw e;
Expand Down

0 comments on commit fe9e2b6

Please sign in to comment.