您已将自定义
Exception扩展自
IOException
public class MyCustomException extends IOException {该
ResponseErrorHandler#handleError()方法是从调用
RestTemplate#handleResponseError(..)其通过调用
RestTemplate#doExecute(..)。此根调用被包装在一个
try-catch块中,该块被捕获
IOException并重新包装在a中
ResourceAccessException,即a
RestClientException。
一种可能性是抓住
RestClientException并获得成功
cause。
另一种可能性是使您的自定义
Exception成为的子类型
RuntimeException。



