Improve documentation for custom exception requirements for RestClient #31783
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: documentation
A documentation task
Milestone
Affects: 6.1.1
It was not immediately clear to me, that custom exceptions cannot be any of the following types:
UncheckedIOException
IOException
HttpMessageNotReadableException
If for example you define an exception as:
And attempt to throw it in a status handler:
Does not work.
Instead a
RestClientException
is thrown because the (3) exceptions I listed above are explicitly caught here and as a result, to access your custom exception, you have to unwrap it:The same also applies when using
defaultStatusHandler
when building theRestClient
as well.It would be nice to mention somewhere in the documentation and Javadoc that custom exceptions cannot be either of the (3) types above nor extend those types in some way otherwise a
RestClientException
will be thrown, not your custom exception.Minimal Spring Boot example
The text was updated successfully, but these errors were encountered: