Best practices for handling planetscale DatabaseErrors with Drizzle?
How are you meant to catch certain/expected DB errors in your server code? This would be useful, for instance, to repeat insertion with a different ID if a user already exists.
Problem is, unlike Prisma, I don't seem to be able to access a mysql error code, all I get is an error message string like
target: xyz.-.primary: vttablet: rpc error: code = AlreadyExists desc = Duplicate entry '1' for key 'user.user_username_unique' (errno 1062) (sqlstate 23000) ....
Is my best bet really to parse the code using regex?
2 Replies
upvoting this
did you find a way to do this? @Domski
Unfortunately not, no