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