From 7a3a2a6ea2391caee7965293f8bd943d5e470fe6 Mon Sep 17 00:00:00 2001 From: hyperbola Date: Fri, 16 Aug 2024 20:51:21 +0800 Subject: [PATCH] feat: truncate error string if it is too long 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. --- src/error.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/error.ts b/src/error.ts index fae0552..b28ca02 100644 --- a/src/error.ts +++ b/src/error.ts @@ -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)} ` + } + core.debug(str_err) if (error instanceof Error) { core.setFailed(`Unknown error occurred: ${error.message}`) } else {