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 +};