Open divan opened 1 year ago
I don't think that there is structured information like that by default. I may be wrong though. I'll double check tomorrow. However, you can override the error message with whatever you want including structured data like json. You will still have to parse it, but its better than parsing an error message.
Here is a link to the relevant documentation. errmessage
is the bit that changes the message.
I confirmed that the server doesn't send any structured data that indicates which constraint has been violated.
@fmoor thanks! Not high a priority, but would be nice to have it someday to make error handling more reliable.
For whoever stumbles on this issue, we plan to refactor errors in EdgeQL it self. This will improve a lot of things. Information about constraint violations being one of them.
Is it possible to extract information about constraint violation error from
edgedb.Error
?Idea is that I'm interested in knowing which field exactly has violated constraints (say, is it an
email
field of User or something else), so the different actions can be taken.Seems like right now the only way is to parse a string "email violates exclusivity constraint", which is not reliable way in a long term.