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

Function withServiceLogging

apps/cloud/src/auth/errors.ts:107–120  ·  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

105 * public shape.
106 */
107export const withServiceLogging = <A, E, R>(
108 name: string,
109 // Receives the raw failure (for service adapters: the `ServiceAdapterError`
110 // whose `.cause` is the SDK exception) so the public error can carry safe
111 // classification fields (e.g. `WorkOSError.status`). Zero-arg callers that
112 // ignore the failure keep working unchanged.
113 publicError: (failure: unknown) => E,
114 effect: Effect.Effect<A, unknown, R>,
115): Effect.Effect<A, E, R> =>
116 effect.pipe(
117 Effect.tapCause((cause) => Effect.logError(`${name} failed`, cause)),
118 Effect.mapError(publicError),
119 Effect.withSpan(name),
120 ) as Effect.Effect<A, E, R>;

Callers 3

makeServiceFunction · 0.90
useFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected