Skip to content

Commit

Permalink
fix: Enhance error logging by refining stack trace extraction and imp…
Browse files Browse the repository at this point in the history
…roving file path formatting in index.ts and index.js
  • Loading branch information
austenstone committed Nov 26, 2024
1 parent fe9e2b6 commit 8a6fb44
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
11 changes: 8 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29154,15 +29154,20 @@ try {
}
catch (e) {
if (e instanceof Error) {
const lastStackEntry = e.stack?.split("\n").pop()?.split(":");
const lastStackEntry = e.stack
?.split("\n")
.pop()
?.split("at ")
.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}/`, "");
stackInfo.file = stackInfo.file?.replace(/^([^\/]+\/){5}/, "");
(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,
Expand All @@ -29171,7 +29176,7 @@ catch (e) {
}
throw e;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9DOi9Vc2Vycy9hdXN0ZS9zb3VyY2UvYWN0aW9uLXR5cGVzY3JpcHQvc3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsSUFBSSxFQUFFLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDN0QsT0FBTyxFQUFFLE9BQU8sRUFBRSxVQUFVLE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Q0FBQyxDQUFDLE9BQU8sRUFBRTtZQUNmLEtBQUssRUFBRSxDQUFDLENBQUMsSUFBSTtZQUNiLEdBQUcsU0FBUztTQUNiLENBQUMsQ0FBQztJQUNMLENBQUM7SUFDRCxNQUFNLENBQUMsQ0FBQztBQUNWLENBQUMifQ==
__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.

12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ try {
});
} catch (e) {
if (e instanceof Error) {
const lastStackEntry = e.stack?.split("\n").pop()?.split(":");
const lastStackEntry = e.stack
?.split("\n")
.pop()
?.split("at ")
.pop()
?.split(":");
const stackInfo = lastStackEntry
? {
file: lastStackEntry[0],
Expand All @@ -34,10 +39,7 @@ try {
}
: {};

stackInfo.file?.replace(
`/home/runner/work/${context.repo.owner}/${context.repo.repo}/`,
"",
);
stackInfo.file = stackInfo.file?.replace(/^([^\/]+\/){5}/, "");

Check failure on line 42 in src/index.ts

View workflow job for this annotation

GitHub Actions / ci

Unnecessary escape character: \/
info(`Stack: ${JSON.stringify(stackInfo, null, 2)}`);
error(e.message, {
title: e.name,
Expand Down

0 comments on commit 8a6fb44

Please sign in to comment.