| 115 | const isInternalError = Schema.is(InternalError); |
| 116 | |
| 117 | export const captureEngineError = <A, R>( |
| 118 | eff: Effect.Effect<A, Cause.YieldableError, R>, |
| 119 | ): Effect.Effect<A, InternalError, R> => |
| 120 | eff.pipe( |
| 121 | Effect.catch((err) => |
| 122 | isInternalError(err) |
| 123 | ? Effect.fail(err) |
| 124 | : resolveCapture.pipe( |
| 125 | Effect.flatMap((c) => c.captureException(Cause.fail(err))), |
| 126 | Effect.flatMap((traceId) => Effect.fail(new InternalError({ traceId }))), |
| 127 | ), |
| 128 | ), |
| 129 | ); |
| 130 | |
| 131 | /** |
| 132 | * Edge defect catchall. Builds an `HttpApiBuilder.middleware` layer |