Skip to content

Commit

Permalink
feat: truncate error string if it is too long
Browse files Browse the repository at this point in the history
We use esbuild to transform ts files to js ones. When handling
unexpected error messages, it may print the transpiled minified js file
code. This is meaningless, so if the stringified error is too long,
truncate it.
  • Loading branch information
wdzeng committed Aug 16, 2024
1 parent 37c0d44 commit 7a3a2a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export function handleError(error: unknown): never {
}

// Unknown error. This may be a bug of this action.
core.debug(stringify(error))
let str_err = stringify(error)
if (str_err.length > 256) {
str_err = `${str_err.slice(0, 256)} <truncated>`
}
core.debug(str_err)
if (error instanceof Error) {
core.setFailed(`Unknown error occurred: ${error.message}`)
} else {
Expand Down

0 comments on commit 7a3a2a6

Please sign in to comment.