So how do I convert these intense Rust erorrs into...
# orm-help
g
So how do I convert these intense Rust erorrs into something usable?
Copy code
Error occurred during query execution:

ConnectorError(ConnectorError { user_facing_error: Some(KnownError { message: "Unique constraint failed on the constraint: `PRIMARY`", meta: Object({"target": String("PRIMARY")}), error_code: "P2002" }), kind: UniqueConstraintViolation { constraint: Index("PRIMARY") } })
Like … i know what the error means, but are devs expected to implement their own parser for this?
How are folks currently dealing with such errors?
what I’d like is to turn that monstrocity into something like:
Copy code
{
  reason: 'unique_constraint_violation',
}
o
You could search for unique constraint violation in the catch block of t try catch and return the message you actually want. .
r
Yeah that’s the only way to do it for now or use the corresponding error code.
j
Optimally you should get this not as this "intense Rust error" but already in a readable form in the Prisma Client.
If that is not the case, please open an issue and provide all the information you have.