MCPcopy
hub / github.com/prisma/prisma / wrapSync

Function wrapSync

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

Source from the content-addressed store, hash-verified

159}
160
161function 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}

Callers 1

bindAdapterFunction · 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