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

Function withServiceLogging

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

198 * public shape.
199 */
200export const withServiceLogging = <A, E, R>(
201 name: string,
202 // Receives the raw failure (for service adapters: the `ServiceAdapterError`
203 // whose `.cause` is the SDK exception) so the public error can carry safe
204 // classification fields (e.g. `WorkOSError.status`). Zero-arg callers that
205 // ignore the failure keep working unchanged.
206 publicError: (failure: unknown) => E,
207 effect: Effect.Effect<A, unknown, R>,
208): Effect.Effect<A, E, R> =>
209 effect.pipe(
210 Effect.tapCause((cause) => Effect.logError(`${name} failed`, cause)),
211 Effect.mapError(publicError),
212 Effect.withSpan(name),
213 ) as Effect.Effect<A, E, R>;

Callers 3

makeServiceFunction · 0.90
useFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected