Extracting Nested Errors in `effect/Cause` with `@effect/sql-drizzle` and `@effect/sql`
Hey everyone! I'm unsure which channel to post this in as it is mostly concering
The minimal repro lives in the repo I'm working on.
packages/_internal/db-admin/src/execute.ts shows the brute-force version. The only way I can reach the underlying postgres.PostgresError inside the SqlError cause is to JSON round-trip the DrizzleQueryError – without that the nested FiberFailure keeps the Postgres error hidden behind non-enumerable symbols.
Am I missing an existing helper for exposing the original PostgresError (or even just the innermost failure) from a SqlError? Ideally I'd like to map a failed query to a DbError without the serialization trick or having to manually walk every property.
At the end of the day I would like to create a robust
Any pointers or examples would be super appreciated.
effect/Cause. I'm digging into how Cause nests failures when using @effect/sql-drizzle + @effect/sql.The minimal repro lives in the repo I'm working on.
packages/_internal/db-admin/src/execute.ts shows the brute-force version. The only way I can reach the underlying postgres.PostgresError inside the SqlError cause is to JSON round-trip the DrizzleQueryError – without that the nested FiberFailure keeps the Postgres error hidden behind non-enumerable symbols.
Am I missing an existing helper for exposing the original PostgresError (or even just the innermost failure) from a SqlError? Ideally I'd like to map a failed query to a DbError without the serialization trick or having to manually walk every property.
At the end of the day I would like to create a robust
DbError class with a static method called match or something that could take an unknown input and do some Cause / pattern matching magic to return a new DbError instance with as much error information as possible and wouldn't mind some tips/trick's as to some clean & ergonomic ways to accomplish this as I have yet to come to a satisfactory solution:Any pointers or examples would be super appreciated.
