From 441582a14d272a2443e4a7bd1097d5f3895a8886 Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:59:44 -0500 Subject: [PATCH] add health util for error catching --- healthUtil.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/healthUtil.ts b/healthUtil.ts index 8c8b5db..a98e39a 100644 --- a/healthUtil.ts +++ b/healthUtil.ts @@ -35,3 +35,9 @@ export const guardDurationAboveMinimum = ( (input.duration <= input.minimumTime) ? Promise.reject(errorCode(60, "Starting")) : null; + +export const catchError = (effects: Effects) => (e: unknown) => { + const error = (error: string) => ({ error }); + effects.error(`Health check failed: ${e}`); + return error("Error while running health check"); +}; \ No newline at end of file