( registry: ErrorRegistryInternal, fn: (...args: A) => R, )
| 159 | } |
| 160 | |
| 161 | function wrapSync<A extends unknown[], R>( |
| 162 | registry: ErrorRegistryInternal, |
| 163 | fn: (...args: A) => R, |
| 164 | ): (...args: A) => Result<R> { |
| 165 | return (...args) => { |
| 166 | try { |
| 167 | return ok(fn(...args)) |
| 168 | } catch (error) { |
| 169 | debug('[error@wrapSync]', error) |
| 170 | |
| 171 | // unwrap the cause of exceptions thrown by driver adapters if there is one |
| 172 | if (isDriverAdapterError(error)) { |
| 173 | return err(error.cause) |
| 174 | } |
| 175 | const id = registry.registerNewError(error) |
| 176 | return err({ kind: 'GenericJs', id }) |
| 177 | } |
| 178 | } |
| 179 | } |
no test coverage detected