@Test void handleAuthException() throws NoSuchFieldException { FieldSetter.setField(service, service.getClass().getDeclaredField("objectMapper"), STATIC_MAPPER); ResponseEntity<Map> result = service.handleAuthException(AuthorizationException.builder().devMessage("Msg").errorCode(AuthErrorCode.ACCESS_FORBIDDEN).build()); compareBodies(result, ResponseEntity.status(HttpStatus.FORBIDDEN).body(getExpected(403, "Msg"))); }
@ExceptionHandler(AuthorizationException.class) public ResponseEntity<Map> handleAuthException(AuthorizationException e) { HttpStatus status = AuthorizationExceptionStatusResolver.resolveHttpStatusByCode(e.getErrorCode()); Map message = buildContentMap(status.value(), e.getDevMessage()); return ResponseEntity.status(status).body(message); }
GlobalExceptionHandler { @ExceptionHandler(AuthorizationException.class) public ResponseEntity<Map> handleAuthException(AuthorizationException e) { HttpStatus status = AuthorizationExceptionStatusResolver.resolveHttpStatusByCode(e.getErrorCode()); Map message = buildContentMap(status.value(), e.getDevMessage()); return ResponseEntity.status(status).body(message); } }
GlobalExceptionHandler { @ExceptionHandler(AuthorizationException.class) public ResponseEntity<Map> handleAuthException(AuthorizationException e) { HttpStatus status = AuthorizationExceptionStatusResolver.resolveHttpStatusByCode(e.getErrorCode()); Map message = buildContentMap(status.value(), e.getDevMessage()); return ResponseEntity.status(status).body(message); }  }
GlobalExceptionHandler { @ExceptionHandler(AuthorizationException.class) public ResponseEntity<Map> handleAuthException(AuthorizationException e) { HttpStatus status = AuthorizationExceptionStatusResolver.resolveHttpStatusByCode(e.getErrorCode()); Map message = buildContentMap(status.value(), e.getDevMessage()); return ResponseEntity.status(status).body(message); }  @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(AuthorizationException.class) public ResponseEntity<Map> handleAuthException(AuthorizationException e) { HttpStatus status = AuthorizationExceptionStatusResolver.resolveHttpStatusByCode(e.getErrorCode()); Map message = buildContentMap(status.value(), e.getDevMessage()); return ResponseEntity.status(status).body(message); }  @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);  }