Skip to content

Commit 75d8298

Browse files
authored
Update rest-client.adoc
I believe we are supposed to __return__ the exception, not throw it. As throwing circumvents whatever may happen after toThrowable returns.
1 parent b3997e8 commit 75d8298

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/src/main/asciidoc/rest-client.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ public class MyResponseExceptionMapper implements ResponseExceptionMapper<Runtim
13821382
@Override
13831383
public RuntimeException toThrowable(Response response) {
13841384
if (response.getStatus() == 500) {
1385-
throw new RuntimeException("The remote service responded with HTTP 500");
1385+
return new RuntimeException("The remote service responded with HTTP 500");
13861386
}
13871387
return null;
13881388
}
@@ -1392,7 +1392,7 @@ public class MyResponseExceptionMapper implements ResponseExceptionMapper<Runtim
13921392
`ResponseExceptionMapper` also defines the `getPriority` method which is used in order to determine the priority with which `ResponseExceptionMapper` implementations will be called (implementations with a lower value for `getPriority` will be invoked first).
13931393
If `toThrowable` returns an exception, then that exception will be thrown. If `null` is returned, the next implementation of `ResponseExceptionMapper` in the chain will be called (if there is any).
13941394

1395-
The class as written above, would not be automatically be used by any REST Client. To make it available to every REST Client of the application, the class needs to be annotated with `@Provider` (as long as `quarkus.rest-client.provider-autodiscovery` is not set to `false`).
1395+
The class as written above, would not be automatically used by any REST Client. To make it available to every REST Client of the application, the class needs to be annotated with `@Provider` (as long as `quarkus.rest-client.provider-autodiscovery` is not set to `false`).
13961396
Alternatively, if the exception handling class should only apply to specific REST Client interfaces, you can either annotate the interfaces with `@RegisterProvider(MyResponseExceptionMapper.class)`, or register it using configuration using the `providers` property of the proper `quarkus.rest-client` configuration group.
13971397

13981398
=== Using @ClientExceptionMapper

0 commit comments

Comments
 (0)