MCPcopy
hub / github.com/prisma/prisma / wrapAsync

Function wrapAsync

packages/driver-adapter-utils/src/binder.ts:141–159  ·  view source on GitHub ↗
(
  registry: ErrorRegistryInternal,
  fn: (...args: A) => Promise<R>,
)

Source from the content-addressed store, hash-verified

139}
140
141function 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
161function wrapSync<A extends unknown[], R>(
162 registry: ErrorRegistryInternal,

Callers 4

bindSqlAdapterFactoryFunction · 0.85
bindAdapterFunction · 0.85
bindTransactionFunction · 0.85

Calls 6

okFunction · 0.90
isDriverAdapterErrorFunction · 0.90
errFunction · 0.90
debugFunction · 0.85
registerNewErrorMethod · 0.80
fnFunction · 0.50

Tested by

no test coverage detected