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

Machine friendly exceptions #4

Closed
danielpetisme opened this issue Jan 6, 2020 · 10 comments · Fixed by #183
Closed

Machine friendly exceptions #4

danielpetisme opened this issue Jan 6, 2020 · 10 comments · Fixed by #183
Labels
$$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ enhancement New feature or request $200 https://www.jhipster.tech/bug-bounties/

Comments

@danielpetisme
Copy link
Member

JHipster Spring integrates Zalando problems (more precisely the spring version of the lib) to transform Java exception into machine readable exceptions (ie. HTTP status code + a JSON document).

Quarkus does not provide out of the box such feature. The objective is to emulate the same behavior (or simply try to integrate the vanilla Zalando problem lib) in order to be pluggable to the default front applications.

@deepu105 deepu105 added $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ $100 https://www.jhipster.tech/bug-bounties/ labels Jan 26, 2020
@joewhite101
Copy link
Contributor

joewhite101 commented Aug 27, 2020

is this one the same as #17?

@danielpetisme
Copy link
Member Author

@joewhite101 yes could be considered as duplicate.
The initial issue wasn't assuming any library choice but to be honest I don't know any good alternative to Zalando problems.
In other hands, I don't even know if it's feasible.

I'll close #17 and continue the discussion on this one.

@jdubois jdubois added $200 https://www.jhipster.tech/bug-bounties/ and removed $100 https://www.jhipster.tech/bug-bounties/ labels Aug 28, 2020
@joewhite101 joewhite101 added the enhancement New feature or request label Aug 28, 2020
@inngvar
Copy link
Contributor

inngvar commented Sep 3, 2020

I can try to integrate it using https://github.com/cloudstark/quarkus-zalando-problem-extension extension.

@danielpetisme
Copy link
Member Author

Definitively worth to try! Awesome if someone already made the integration.
I don't see a lot of activity on the project, so if the experimentation is successful I propose we should contact the project authors.
The idea is to be sure we could get some help when people will generate JHipster projects with the zalando extension. Otherwise would make senses to re-implement it (and prevent a coupling on an inactive project).

@lwitkowski
Copy link
Contributor

@danielpetisme I can give it a shot with a new extension published recently I'm contributing to that fits this issue pretty well.

I've already had a quick look, and it would save me a lot of time to know if there will be some changes needed in the frontend as well? Can frontend app leverage problem schema to display better error messages etc?

@danielpetisme
Copy link
Member Author

Hi,

The front end is already configured to handle problem payloads.
JHipster defines custom errors too that have to be translated into Quarkus Problems
https://github.com/jhipster/jhipster-sample-app/tree/main/src/main/java/io/github/jhipster/sample/web/rest/errors
The tricky part is this one
https://github.com/jhipster/jhipster-sample-app/blob/main/src/main/java/io/github/jhipster/sample/web/rest/errors/ExceptionTranslator.java

How can I help you to move forward?

@lwitkowski
Copy link
Contributor

Thanks for hints, that sounds very good. the tricky part should just work, as ThrowableProblems are explicitly supported by our extension.
Could you also point me to specific action in UI I have to do (click) to see one of these exceptions returned from backend service and what should I see in the browser? I'll try to run sprinboot version later today to find out myself though :)

@danielpetisme
Copy link
Member Author

🤔
The basic errors are defined here:
https://github.com/jhipster/jhipster-sample-app/blob/main/src/main/java/io/github/jhipster/sample/web/rest/errors/ErrorConstants.java

To try to force an error, you can startup a generated app, log with the admin account (admin/admin), go to the Administration > User Management menu. Try to create a new user with an existing login for instance

@lwitkowski
Copy link
Contributor

Thanks again, I see that quarkus generator uses raw WebApplicationExceptions or even RuntimeException here and there, which I'll probably have to convert into ThrowableProblems to fully take advantage of application/problem+json, but that's fine, I'm on it.

@lwitkowski
Copy link
Contributor

@danielpetisme you may want to have a first look at draft PR with first working implementation, I've checked both maven and gradle versions with multiple languages (but only selected subset of exceptions) - looks ok.

One thing that worries me a bit is that I didn't have to change a single test and all are green - do you think I should address it somehow and include some checks on response bodies (application/problem+json)?

lwitkowski added a commit to lwitkowski/generator-jhipster-quarkus that referenced this issue Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
$$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ enhancement New feature or request $200 https://www.jhipster.tech/bug-bounties/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants