MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / withServiceLogging

Function withServiceLogging

apps/cloud/src/auth/errors.ts:221–234  ·  view source on GitHub ↗
(
  name: string,
  // Receives the raw failure (for service adapters: the `ServiceAdapterError`
  // whose `.cause` is the SDK exception) so the public error can carry safe
  // classification fields (e.g. `WorkOSError.status`). Zero-arg callers that
  // ignore the failure keep working unchanged.
  publicError: (failure: unknown) => E,
  effect: Effect.Effect<A, unknown, R>,
)

Source from the content-addressed store, hash-verified

219 * public shape.
220 */
221export const withServiceLogging = <A, E, R>(
222 name: string,
223 // Receives the raw failure (for service adapters: the `ServiceAdapterError`
224 // whose `.cause` is the SDK exception) so the public error can carry safe
225 // classification fields (e.g. `WorkOSError.status`). Zero-arg callers that
226 // ignore the failure keep working unchanged.
227 publicError: (failure: unknown) => E,
228 effect: Effect.Effect<A, unknown, R>,
229): Effect.Effect<A, E, R> =>
230 effect.pipe(
231 Effect.tapCause((cause) => Effect.logError(`${name} failed`, cause)),
232 Effect.mapError(publicError),
233 Effect.withSpan(name),
234 ) as Effect.Effect<A, E, R>;

Callers 5

runFunction · 0.90
makeServiceFunction · 0.90
readFunction · 0.90
useFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected