I am using SpringBoot with RestTemplate to communicate with another application. However, I am unable to change its API and this external service always Returns 200OK return code.
By Default, we have ResponseErrorHandler that reacts to all 4xx and 5xx response codes but in my case when there is an exception I get 200OK with one JSON field errors.
I have created a custom error handler and bundled it into my rest template by using:
restTemplate.errorHandler(new MyCustomErrorHandler());
I have also overrided hasError() method but inside I have to parse this object to check whether it contains fields with errors...
Is this a good approach for error handling? Should I parse response twice? I seek for the clean solution for such problems but I want to avoid parsing message twice every time I use external service