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