From 2138938e52a8d84d25ccad4beaa2f6e97d35f179 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Fri, 27 Sep 2024 11:17:35 +1200 Subject: [PATCH] fix: ensure failure is set before attempting to log and handle unknown throws --- src/return-dispatch.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/return-dispatch.ts b/src/return-dispatch.ts index aa745471..913f3dc8 100644 --- a/src/return-dispatch.ts +++ b/src/return-dispatch.ts @@ -192,10 +192,17 @@ export async function returnDispatch( core.setFailed("Timeout exceeded while attempting to get Run ID"); } catch (error) { if (error instanceof Error) { - core.error(`Failed: ${error.message}`); - core.warning("Does the token have the correct permissions?"); + const failureMsg = `Failed: An unhandled error has occurred: ${error.message}`; + core.setFailed(failureMsg); + core.error(failureMsg); core.debug(error.stack ?? ""); - core.setFailed(error.message); + } else { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + const failureMsg = `Failed: An unknown error has occurred: ${error}`; + core.setFailed(failureMsg); + core.error(failureMsg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + core.debug(error as any); } } }