diff --git a/src/common/utils/with-error-logging/with-error-logging.injectable.ts b/src/common/utils/with-error-logging/with-error-logging.injectable.ts index fcdf86e047..d019d5d392 100644 --- a/src/common/utils/with-error-logging/with-error-logging.injectable.ts +++ b/src/common/utils/with-error-logging/with-error-logging.injectable.ts @@ -5,15 +5,21 @@ import { getInjectable } from "@ogre-tools/injectable"; import loggerInjectable from "../../logger.injectable"; +export type WithErrorLoggingFor = ( + getErrorMessage: (error: Error) => string +) => any>( + toBeDecorated: T +) => (...args: Parameters) => ReturnType; + const withErrorLoggingInjectable = getInjectable({ id: "with-error-logging", - instantiate: (di) => { + instantiate: (di): WithErrorLoggingFor => { const logger = di.inject(loggerInjectable); - return (getErrorMessage: (error: Error) => string) => - any>(toBeDecorated: T) => - (...args: Parameters): ReturnType => { + return (getErrorMessage) => + (toBeDecorated) => + (...args) => { try { const returnValue = toBeDecorated(...args);