( registry: ErrorRegistryInternal, fn: (...args: A) => Promise<R>, )
| 139 | } |
| 140 | |
| 141 | function wrapAsync<A extends unknown[], R>( |
| 142 | registry: ErrorRegistryInternal, |
| 143 | fn: (...args: A) => Promise<R>, |
| 144 | ): (...args: A) => Promise<Result<R>> { |
| 145 | return async (...args) => { |
| 146 | try { |
| 147 | return ok(await fn(...args)) |
| 148 | } catch (error) { |
| 149 | debug('[error@wrapAsync]', error) |
| 150 | |
| 151 | // unwrap the cause of exceptions thrown by driver adapters if there is one |
| 152 | if (isDriverAdapterError(error)) { |
| 153 | return err(error.cause) |
| 154 | } |
| 155 | const id = registry.registerNewError(error) |
| 156 | return err({ kind: 'GenericJs', id }) |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | function wrapSync<A extends unknown[], R>( |
| 162 | registry: ErrorRegistryInternal, |
no test coverage detected