Prisma 7 + Neon Adapter: Unique Constraint Errors Not Throwing P2002

Hey! I'm using Prisma 7+ with the Neon serverless adapter, and I'm trying to properly handle unique constraint violations.
With regular Prisma, I would normally catch this using:

if (err instanceof PrismaClientKnownRequestError && err.code === "P2002") {
    // err.meta.target gives the failing field
}


However, when running with Neon, I’m not getting a P2002 error at all.
Instead, Prisma throws a DriverAdapterError that looks like this:

{
        "modelName": "User",
        "driverAdapterError": {
            "name": "DriverAdapterError",
            "cause": {
                "originalCode": "23505",
                "originalMessage": "duplicate key value violates unique constraint \"User_email_key\"",
                "kind": "UniqueConstraintViolation",
                "constraint": {
                    "fields": [
                        "email"
                    ]
                }
            }
        }
    }


Is there a more stable or official method for extracting the unique field name when using Prisma + Neon?
Any guidance or best practices would be appreciated! Thank you!
Was this page helpful?