I have the following exception handler:
@RestControllerAdvice
@RequiredArgsConstructor
public class ControllerExceptionHandler {
@ExceptionHandler(FeignException.class)
@ResponseBody
public String afterThrowing(FeignException ex, HttpServletResponse response) {
response.setStatus(ex.status());
return ex.contentUTF8();
}
}
I would expect when the FeignException
propagates to one of my REST controllers that
- The
afterThrowing
method would be called - The response returned to an HTTP client would be JSON
The method is called but the content type returned to the client is HTML instead of JSON. How can I have JSON returned instead of HTML?