@Test void handleFeignException() throws NoSuchMethodException, JsonProcessingException, NoSuchFieldException { FieldSetter.setField(service, service.getClass().getDeclaredField("objectMapper"), STATIC_MAPPER); ResponseEntity<Map> result = service.handleFeignException(FeignException.errorStatus("method", getResponse()), new HandlerMethod(service, "toString", null)); ResponseEntity<Map<String, String>> expected = ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(getExpected(401, "status 401 reading method")); compareBodies(result, expected); }
@ExceptionHandler(FeignException.class) public ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod) { log.warn("FeignException handled in service: {}, message: {}", handlerMethod.getMethod().getDeclaringClass().getSimpleName(), ex.getMessage()); Map<String, String> body = buildContentMap(ex.status(), resolveErrorMessage(ex)); HttpStatus status = HttpStatus.valueOf(ex.status() == 0 ? 503 : ex.status()); return new ResponseEntity<>(body, status); }
TppExceptionAdvisor { @ExceptionHandler(FeignException.class) public ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod) { log.warn("FeignException handled in service: {}, message: {}", handlerMethod.getMethod().getDeclaringClass().getSimpleName(), ex.getMessage()); Map<String, String> body = buildContentMap(ex.status(), resolveErrorMessage(ex)); HttpStatus status = HttpStatus.valueOf(ex.status() == 0 ? 503 : ex.status()); return new ResponseEntity<>(body, status); } }
TppExceptionAdvisor { @ExceptionHandler(FeignException.class) public ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod) { log.warn("FeignException handled in service: {}, message: {}", handlerMethod.getMethod().getDeclaringClass().getSimpleName(), ex.getMessage()); Map<String, String> body = buildContentMap(ex.status(), resolveErrorMessage(ex)); HttpStatus status = HttpStatus.valueOf(ex.status() == 0 ? 503 : ex.status()); return new ResponseEntity<>(body, status); }  }
TppExceptionAdvisor { @ExceptionHandler(FeignException.class) public ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod) { log.warn("FeignException handled in service: {}, message: {}", handlerMethod.getMethod().getDeclaringClass().getSimpleName(), ex.getMessage()); Map<String, String> body = buildContentMap(ex.status(), resolveErrorMessage(ex)); HttpStatus status = HttpStatus.valueOf(ex.status() == 0 ? 503 : ex.status()); return new ResponseEntity<>(body, status); }  @ExceptionHandler(value = Exception.class) ResponseEntity<Map> handleException(Exception ex, HandlerMethod handlerMethod); @ExceptionHandler(TppException.class) ResponseEntity<Map> handleTppException(TppException ex, HandlerMethod handlerMethod); @ExceptionHandler(FeignException.class) ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod); @ExceptionHandler(IllegalArgumentException.class) ResponseEntity<Map> handleIllegalArgumentException(IllegalArgumentException ex, HandlerMethod handlerMethod); }
TppExceptionAdvisor { @ExceptionHandler(FeignException.class) public ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod) { log.warn("FeignException handled in service: {}, message: {}", handlerMethod.getMethod().getDeclaringClass().getSimpleName(), ex.getMessage()); Map<String, String> body = buildContentMap(ex.status(), resolveErrorMessage(ex)); HttpStatus status = HttpStatus.valueOf(ex.status() == 0 ? 503 : ex.status()); return new ResponseEntity<>(body, status); }  @ExceptionHandler(value = Exception.class) ResponseEntity<Map> handleException(Exception ex, HandlerMethod handlerMethod); @ExceptionHandler(TppException.class) ResponseEntity<Map> handleTppException(TppException ex, HandlerMethod handlerMethod); @ExceptionHandler(FeignException.class) ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod); @ExceptionHandler(IllegalArgumentException.class) ResponseEntity<Map> handleIllegalArgumentException(IllegalArgumentException ex, HandlerMethod handlerMethod);  }