Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get details of ConstraintViolationError #269

Open
divan opened this issue Mar 27, 2023 · 5 comments
Open

Get details of ConstraintViolationError #269

divan opened this issue Mar 27, 2023 · 5 comments

Comments

@divan
Copy link
Contributor

divan commented Mar 27, 2023

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.

@fmoor
Copy link
Member

fmoor commented Mar 27, 2023

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.

@fmoor
Copy link
Member

fmoor commented Mar 27, 2023

Here is a link to the relevant documentation. errmessage is the bit that changes the message.

@fmoor
Copy link
Member

fmoor commented Mar 27, 2023

I confirmed that the server doesn't send any structured data that indicates which constraint has been violated.

@divan
Copy link
Contributor Author

divan commented Mar 28, 2023

@fmoor thanks! Not high a priority, but would be nice to have it someday to make error handling more reliable.

@fmoor
Copy link
Member

fmoor commented Oct 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants