Spring Boot の RestTemplate で 500 系エラーが発生した場合でも reponse header / body の中身を取得する
困ったこと
RestTemplate で http request を送って 500 系のエラーが帰ってきた場合、
RestClientException
が送出され、戻り値としては http response が取得できない。解決方法
RestClientException
のサブクラスである RestClientResponseException
を catch すること。Java
Common base class for exceptions that contain actual HTTP response data.
とのことなので。