Skip to content

Commit

Permalink
rename: 예외 처리 클래스명 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
dtd1614 committed May 16, 2024
1 parent acb4de2 commit 7128bbf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package today.meevote.controllerAdvice;

import org.springframework.web.bind.annotation.ExceptionHandler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import today.meevote.exception.view.UnauthenticatedException;
import today.meevote.exception.view.NotFoundException;
import today.meevote.response.BaseResponse;
import today.meevote.response.FailureInfo;

@org.springframework.web.bind.annotation.ControllerAdvice
@Slf4j
public class ControllerAdvice {
@ControllerAdvice
public class GlobalExceptionHandler {

@ExceptionHandler(UnauthenticatedException.class)
public String unauthenticatedException(UnauthenticatedException e){
Expand All @@ -21,5 +24,15 @@ public String notFoundException(NotFoundException e) {
log.error("notFoundException", e);
return "redirect:/notfound";
}



@ExceptionHandler(MethodArgumentNotValidException.class)
protected BaseResponse methodArgumentNotValidException(MethodArgumentNotValidException e){
log.error("invalidInputException", e);
return new BaseResponse(
false,
FailureInfo.INVALID_INPUT.getCode(),
e.getFieldError().getDefaultMessage()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import today.meevote.exception.rest.RestException;
import today.meevote.response.BaseResponse;
import today.meevote.response.FailureInfo;

@org.springframework.web.bind.annotation.RestControllerAdvice
@Slf4j
public class RestControllerAdvice {
@RestControllerAdvice
public class RestGlobalExceptionHandler {

@ExceptionHandler(Exception.class)
protected BaseResponse internalSeverException(Exception e){
Expand All @@ -38,7 +38,7 @@ protected BaseResponse constraintViolationException(ConstraintViolationException
e.getConstraintViolations().stream().toList().get(0).getMessage()
);
}

@ExceptionHandler(RestException.class)
protected BaseResponse restException(RestException e){
log.error("restException", e);
Expand Down

0 comments on commit 7128bbf

Please sign in to comment.