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

Make it easier for RESTEasy Reactive users to handle Hibernate related exceptions #20509

Merged
merged 2 commits into from
Oct 5, 2021

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Oct 1, 2021

No description provided.

@quarkus-bot quarkus-bot bot added area/hibernate-orm Hibernate ORM area/hibernate-reactive Hibernate Reactive area/persistence OBSOLETE, DO NOT USE area/rest labels Oct 1, 2021

@BuildStep
public UnwrappedExceptionBuildItem unwrappedExceptions() {
return new UnwrappedExceptionBuildItem(PersistenceException.class);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if this should also include HibernateException


@BuildStep
public UnwrappedExceptionBuildItem unwrappedExceptions() {
return new UnwrappedExceptionBuildItem(PersistenceException.class);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if this should also include HibernateException

@geoand geoand requested review from stuartwdouglas and Sanne October 1, 2021 16:05
@Sanne
Copy link
Member

Sanne commented Oct 1, 2021

Sorry I'm totally out of context :) Could you summarize what this is for?

@geoand
Copy link
Contributor Author

geoand commented Oct 1, 2021

Of course!

The idea is to make it very easy for a user to "handle" (in the JAX-RS sense) the actual root cause of an exception.

Take for example the Hibernate ORM quickstart, where trying to save a new Fruit with an existing name leads to a ConstraintViolationException. If a user currently wants to respond to HTTP 400 for that exception, they need handle the RollbackException, then look of the cause is a PersistenceException and check if that one's cause is a ConstraintViolationException.
With this change, writing the JAX-RS ExceptionMapper for that exception is straight forward for the user.

Does that make sense?

@geoand
Copy link
Contributor Author

geoand commented Oct 5, 2021

@Sanne is this good for you as well?

Copy link
Member

@Sanne Sanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks

@Sanne Sanne merged commit ece3e3f into quarkusio:main Oct 5, 2021
@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Oct 5, 2021
@geoand
Copy link
Contributor Author

geoand commented Oct 5, 2021

👍🏼

@geoand geoand deleted the rr-unwrapped2 branch October 5, 2021 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/hibernate-reactive Hibernate Reactive area/persistence OBSOLETE, DO NOT USE area/rest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants