(fn: () => Promise<T>)
| 12 | * and returns a generic unexpected service error. |
| 13 | */ |
| 14 | export const sew = async <T>(fn: () => Promise<T>): Promise<T | ServiceError> => { |
| 15 | try { |
| 16 | return await fn(); |
| 17 | } catch (e) { |
| 18 | Sentry.captureException(e); |
| 19 | logger.error(e); |
| 20 | |
| 21 | if (e instanceof ServiceErrorException) { |
| 22 | return e.serviceError; |
| 23 | } |
| 24 | |
| 25 | return unexpectedError(`An unexpected error occurred. Please try again later.`); |
| 26 | } |
| 27 | }; |
no test coverage detected