-
Notifications
You must be signed in to change notification settings - Fork 1
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
Change error handling strategy and add verbose errors #30
Conversation
95bffb7
to
61eda9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. Also adding @matriv and @seut as optional reviewers, in order to a) give them a chance to spot nitty errors I am regularly missing because my reviewing style may be too lenient, and b) also give them a chance to respond to my first suggestion about API style matters.
Edit: Apologies, I missed to spot this PR is still in draft mode. So, please consider my suggestions as early feedback only.
cc @proddata I'd love your feedback as well as any input on this |
I read through it and generally like the idea of not raising an exception. However, I'm not sure about the defaults. Regarding the "main issue," I don't have a strong opinion as I lack details on the mechanics. If the approach works, though, 👍. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for the work on this @surister !
Left a comment, but I will also checkout the branch and play around a bit, so I can understand better the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx @surister ! LGTM
Summary of the changes / Why this is an improvement
Issue #2
This is one of the first pieces required to finish the feature and its only implemented in Python for early feedback/validation.
Main changes of PR:
Throwing antlr4 parse errors as exceptions is now only enabled by
raise_exception
API influenced by DRF ValidatorsDefault behaviour is not to raise an exception, the reason is that it forces clients to try/catch errors, when you already work with CrateDB in the HTTP protocol you are used to check the json response, rather than catching exceptions, this change of behaviour aims to make integrating with this library as similar as possible as with CrateDB.
Implements an
ExceptionCollectorListener
that collects all errors that are caught, (remember that we useparser.statements
, to support running several queries on the frontends, so several errors can happen simultaneously)Adds more verbose errors
The main issue I would like help with the review: <-------------------------------------
we lose the information on which statement the error belongs to, I tried with different ErrorStrategies and Error listeners but to no avail, also didn't find anything online.
My best effort is to try to match the error's offendingToken query, to any of the parsed statements:
There are a couple of edge cases that I covered but in short, it works reasonable well, even though I'm not a fan of it, maybe you folks way more experience in
antlr4
have an idea?Checklist