Spring Rest Client Exception Handling

后端 未结 2 472
暖寄归人
暖寄归人 2021-02-08 11:09

I am using spring RestTemplate to consume rest services(exposed in spring rest). I am able to consume success scenarios. But for negative scenarios, service returns

2条回答
  •  旧时难觅i
    2021-02-08 11:38

    You might want to distinguish between:

    HttpClientErrorException (HTTP-Status >=400) or HttpServerErrorException (HTTP-Status >= 500) or even RestClientException.

    Further on there is a good doc about defining your own ErrorHandler, see this link

提交回复
热议问题