@Test void handleFeignException() throws JsonProcessingException, NoSuchMethodException, 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)); return new ResponseEntity<>(body, HttpStatus.valueOf(ex.status())); }
GlobalExceptionHandler { @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)); return new ResponseEntity<>(body, HttpStatus.valueOf(ex.status())); } }
GlobalExceptionHandler { @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)); return new ResponseEntity<>(body, HttpStatus.valueOf(ex.status())); }  }
GlobalExceptionHandler { @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)); return new ResponseEntity<>(body, HttpStatus.valueOf(ex.status())); }  @ExceptionHandler(ObaException.class) ResponseEntity<Map> handleAisException(ObaException e); @ExceptionHandler(PaymentAuthorizeException.class) ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e); @ExceptionHandler(AuthorizationException.class) ResponseEntity<Map> handleAuthException(AuthorizationException e); @ExceptionHandler(FeignException.class) ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod); }
GlobalExceptionHandler { @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)); return new ResponseEntity<>(body, HttpStatus.valueOf(ex.status())); }  @ExceptionHandler(ObaException.class) ResponseEntity<Map> handleAisException(ObaException e); @ExceptionHandler(PaymentAuthorizeException.class) ResponseEntity<Map> handlePaymentAuthorizeException(PaymentAuthorizeException e); @ExceptionHandler(AuthorizationException.class) ResponseEntity<Map> handleAuthException(AuthorizationException e); @ExceptionHandler(FeignException.class) ResponseEntity<Map> handleFeignException(FeignException ex, HandlerMethod handlerMethod);  }