| 5 | import type * as SqlError from "effect/unstable/sql/SqlError" |
| 6 | |
| 7 | const queryFailureReason = (cause: unknown) => |
| 8 | Effect.gen(function*() { |
| 9 | const client = yield* PgClient.fromPool({ |
| 10 | acquire: Effect.succeed(makeFailingPool(cause) as any) |
| 11 | }) |
| 12 | const error = yield* Effect.flip(client`SELECT 1`) |
| 13 | return error.reason |
| 14 | }).pipe( |
| 15 | Effect.scoped, |
| 16 | Effect.provide(Reactivity.layer) |
| 17 | ) |
| 18 | |
| 19 | const queryFailureReasonTag = (cause: unknown) => Effect.map(queryFailureReason(cause), (reason) => reason._tag) |
| 20 | |