( 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>, )
| 105 | * public shape. |
| 106 | */ |
| 107 | export 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>; |
no outgoing calls
no test coverage detected