Created
January 5, 2023 12:54
-
-
Save tkafka/bc6157c8facd012a6d7937a083c01829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function wrapInErrorHandler<Func extends (...args: any[]) => any>(func: Func): (...args: InferArguments<Func>) => InferReturn<Func> { | |
return function (...args: InferArguments<Func>) { | |
try { | |
return func.apply(null, args); | |
} catch (err: any) { | |
if (err instanceof LoggedError) { | |
throw err; | |
} | |
post({ your- error - object}); | |
throw new LoggedError(err); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment