-
Notifications
You must be signed in to change notification settings - Fork 5
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
issue 260: add parsing exception handling #266
Conversation
@alexdunnjpl @jordanpadams @nutjob4life @tloubrieu-jpl This is how you solve exception problems. The whole point of reordering the code was to make a single place where exceptions are handled and turned back into http errors. It should become distributed again and certainly not while UserParameters are being instantiated. The better flow and one that currently exists is that you take what is as is and load it into a Java object for simpler processing. Once you have the object and the connection context from spring-something, then you have all the bits you need to start error processing. If you try to do it too early, then you have 10000 different blocks all doing exactly the same exception handling - okay, 4 or so blocks without using hyperbole. The way the code is currently structured, all endpoints have the same error handling because there is this one and only one block that handles exceptions. Not sure why that is so terrible or hard. The advantage is that no more cut-n-paste of code which is the quintessential anti-pattern. So, I see lots of questioning on breaking this all apart and making it more confusing with even more nested exceptions when simply adding to JavaSwaggerTransmutter.process() all that needs to be done because no exception can be thrown outside of that method and that method does all of the exception handling. Miraculous on stop shop. Ready for review. |
@al-niessner is there some context from in-person discussion I've missed, or is this all regarding the in-issue discussion in #252? I'm having some trouble parsing your comment if it's the latter - is the assertion that
is a bad approach, or is there some relation to
? My fault for opening a PR with two unrelated changes I suppose lol. EDIT Oh nevermind - I see the engineering details in #260 which I presume is what you're talking about. Let me know if there's anything in #256 I need to rethink. |
@@ -114,6 +116,10 @@ protected ResponseEntity<Object> processs(EndpointHandler handler, URIParameters | |||
} catch (NothingFoundException e) { | |||
log.warn("Could not find any matching reference(s) in database."); | |||
return new ResponseEntity<Object>(ErrorFactory.build(e, this.request), HttpStatus.NOT_FOUND); | |||
} catch (NoViableAltException | ParseCancellationException e) { | |||
log.warn("The given search string '" + parameters.getQuery() + "' cannot be parsed."); |
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.
Maybe log.info is more appropriate here, given that it's just bad user input?
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.
LGTM
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.
Yes, that is much simpler that what I proposed indeed, thanks Al
@al-niessner @alexdunnjpl I m just realizing that fix does not help yet to fix the ticket #252 but we'll cross that bridge when we will be there. |
Agreed. I opened #252 again with an explanation. |
🗒️ Summary
Another simple one line change to add more exception handling back to HTTP error codes and messaging.
⚙️ Test Data and/or Report
HOWEVER
BECAUSE the error is prior to registry-api in the apache code as the log shows which is a completely different problem:
♻️ Related Issues
closes #260
closes #255
closes #252
closes #206