(cause: unknown)
| 3 | import type * as SqlError from "effect/sql/SqlError" |
| 4 | |
| 5 | const queryFailureReason = (cause: unknown) => { |
| 6 | const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" |
| 7 | ? cause.code |
| 8 | : undefined |
| 9 | const constraint = typeof cause === "object" && cause !== null && "constraint" in cause |
| 10 | ? cause.constraint |
| 11 | : undefined |
| 12 | return classifySqlState(code, constraint, { |
| 13 | cause, |
| 14 | message: "Failed to execute statement", |
| 15 | operation: "query" |
| 16 | }) |
| 17 | } |
| 18 | |
| 19 | const assertUniqueViolation = (reason: SqlError.SqlErrorReason, constraint: string) => { |
| 20 | assert.strictEqual(reason._tag, "UniqueViolation") |
no test coverage detected