Skip to content

Instantly share code, notes, and snippets.

View APZelos's full-sized avatar

Zelos Prapas Alkiviadis APZelos

  • Athens, Greece
View GitHub Profile
@APZelos
APZelos / map_sql_error.ts
Last active September 4, 2025 09:41
Surfacing the `PostgresError` from Drizzle's `DrizzleQueryError` when working with Drizzle in an Effect project.
import type {SqlError} from "@effect/sql"
import * as D from "drizzle-orm"
import {Cause, Chunk, Data, Effect as E, Option, pipe, Runtime} from "effect"
import {PostgresError} from "postgres"
interface KnownPostgresErrorPayload {
cause: PostgresError
sqlError: SqlError.SqlError
detail?: string