public class CustomException을 extends Exception {
public CustomException을() {
}
public CustomException을(String message) {
super(message);
}
public CustomException을(Exception e) {
super(e);
}
}
@ControllerAdvice
public class ControllerExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerExceptionHandler.class);
@SuppressWarnings("unchecked")
@ExceptionHandler({RimsException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
protected ResponseEntity handleApiException(CustomException customException) {
return new ResponseEntity(new ErrorDTO(
customException.getExceptionStatus().getStatusCode(),
customException.getExceptionStatus().getMessage()),
HttpStatus.valueOf(customException.getExceptionStatus().getStatusCode()));
}
@ExceptionHandler({RuntimeException.class})
protected ResponseEntity<String> handleEtcException(CustomException e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
}
}
이를 방지 하기 위해
error vs excetion/ throw , throws / throws Exception 을 사용하는 이유