-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20509 from geoand/rr-unwrapped2
Make it easier for RESTEasy Reactive users to handle Hibernate related exceptions
- Loading branch information
Showing
6 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../java/io/quarkus/hibernate/orm/deployment/ResteasyReactiveServerIntegrationProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.hibernate.orm.deployment; | ||
|
||
import javax.persistence.PersistenceException; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.resteasy.reactive.server.spi.UnwrappedExceptionBuildItem; | ||
|
||
public class ResteasyReactiveServerIntegrationProcessor { | ||
|
||
@BuildStep | ||
public UnwrappedExceptionBuildItem unwrappedExceptions() { | ||
return new UnwrappedExceptionBuildItem(PersistenceException.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../io/quarkus/hibernate/reactive/deployment/ResteasyReactiveServerIntegrationProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.hibernate.reactive.deployment; | ||
|
||
import javax.persistence.PersistenceException; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.resteasy.reactive.server.spi.UnwrappedExceptionBuildItem; | ||
|
||
public class ResteasyReactiveServerIntegrationProcessor { | ||
|
||
@BuildStep | ||
public UnwrappedExceptionBuildItem unwrappedExceptions() { | ||
return new UnwrappedExceptionBuildItem(PersistenceException.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...nt/src/main/java/io/quarkus/resteasy/reactive/server/spi/UnwrappedExceptionBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.resteasy.reactive.server.spi; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* When an Exception of this type is thrown and no {@code javax.ws.rs.ext.ExceptionMapper} exists, | ||
* then RESTEasy Reactive will attempt to locate an {@code ExceptionMapper} for the cause of the Exception. | ||
*/ | ||
public final class UnwrappedExceptionBuildItem extends MultiBuildItem { | ||
|
||
private final Class<? extends Throwable> throwableClass; | ||
|
||
public UnwrappedExceptionBuildItem(Class<? extends Throwable> throwableClass) { | ||
this.throwableClass = throwableClass; | ||
} | ||
|
||
public Class<? extends Throwable> getThrowableClass() { | ||
return throwableClass; | ||
} | ||
} |