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 1/3] 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 From a9d18ab4840650716023342fb7f64e6fb4f50ddc Mon Sep 17 00:00:00 2001 From: J M <2364004+Blu-J@users.noreply.github.com> Date: Tue, 15 Nov 2022 10:08:13 -0700 Subject: [PATCH 2/3] Update healthUtil.ts --- healthUtil.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/healthUtil.ts b/healthUtil.ts index a98e39a..7b4297a 100644 --- a/healthUtil.ts +++ b/healthUtil.ts @@ -1,12 +1,12 @@ import { Effects, ResultType } from "./types.ts"; import { error, errorCode, ok } from "./util.ts"; - export const checkWebUrl: ( url: string, ) => (effects: Effects, duration: number) => Promise> = (url) => { return async (effects, duration) => { - await guardDurationAboveMinimum({ duration, minimumTime: 5000 }); + let errorValue; + if (errorValue = guardDurationAboveMinimum({ duration, minimumTime: 5000 })) return errorValue; return await effects.fetch(url) .then((_) => ok) @@ -33,11 +33,11 @@ export const guardDurationAboveMinimum = ( input: { duration: number; minimumTime: number }, ) => (input.duration <= input.minimumTime) - ? Promise.reject(errorCode(60, "Starting")) + ? 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 +}; From 8630000e8ccb5244dc3e213d5b8c3bf668cde7cc Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Tue, 15 Nov 2022 12:13:19 -0500 Subject: [PATCH 3/3] remove uneeded --- healthUtil.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/healthUtil.ts b/healthUtil.ts index 7b4297a..5481387 100644 --- a/healthUtil.ts +++ b/healthUtil.ts @@ -35,9 +35,3 @@ export const guardDurationAboveMinimum = ( (input.duration <= input.minimumTime) ? 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"); -};