Skip to content

Commit

Permalink
feat: #45 404 error application properties 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
psychology50 committed Dec 21, 2023
1 parent 4559af4 commit 5e43fec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
public class GlobalExceptionHandler {
/**
* API 호출 시 서버에서 발생시킨 전역 예외를 처리하는 메서드
* @param e GlobalErrorException
* @return ResponseEntity<ErrorResponse>
*/
@ExceptionHandler(GlobalErrorException.class)
Expand All @@ -43,7 +42,6 @@ protected ResponseEntity<ErrorResponse> handleGlobalErrorException(GlobalErrorEx

/**
* API 호출 시 인증 관련 예외를 처리하는 메서드
* @param e AuthErrorException
* @return ResponseEntity<ErrorResponse>
*/
@ExceptionHandler(AuthErrorException.class)
Expand All @@ -55,7 +53,6 @@ protected ResponseEntity<ErrorResponse> handleAuthErrorException(AuthErrorExcept

/**
* API 호출 시 인가 관련 예외를 처리하는 메서드
* @param e AccessDeniedException
* @return ResponseEntity<ErrorResponse>
*/
@ResponseStatus(HttpStatus.FORBIDDEN)
Expand All @@ -67,7 +64,6 @@ protected ErrorResponse handleAccessDeniedException(AccessDeniedException e) {

/**
* API 호출 시 객체 혹은 파라미터 데이터 값이 유효하지 않은 경우
* @param e MethodArgumentNotValidException
* @return ResponseEntity<FailureResponse>
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
Expand All @@ -78,6 +74,9 @@ protected ResponseEntity<FailureResponse> handleMethodArgumentNotValidException(
return ResponseEntity.unprocessableEntity().body(response);
}

/**
* API 호출 시 객체 혹은 파라미터 데이터 값이 유효하지 않은 경우
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
protected ResponseEntity<FailureResponse> handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e) {
log.warn("handleMethodArgumentTypeMismatchException: {}", e.getMessage());
Expand All @@ -97,7 +96,6 @@ protected ResponseEntity<FailureResponse> handleMethodArgumentTypeMismatchExcept

/**
* API 호출 시 'Header' 내에 데이터 값이 유효하지 않은 경우
* @param e MissingRequestHeaderException
* @return ResponseEntity<FailureResponse>
*/
@ExceptionHandler(MissingRequestHeaderException.class)
Expand All @@ -109,7 +107,6 @@ protected ResponseEntity<FailureResponse> handleMissingRequestHeaderException(Mi

/**
* API 호출 시 'BODY' 내에 데이터 값이 존재하지 않은 경우
* @param e HttpMessageNotReadableException
* @return ResponseEntity<ErrorResponse>
*/
@ResponseStatus(HttpStatus.BAD_REQUEST)
Expand All @@ -121,7 +118,6 @@ protected ErrorResponse handleHttpMessageNotReadableException(HttpMessageNotRead

/**
* API 호출 시 'Parameter' 내에 데이터 값이 존재하지 않은 경우
* @param e MissingServletRequestParameterException
* @return ResponseEntity<ErrorResponse>
*/
@ResponseStatus(HttpStatus.BAD_REQUEST)
Expand All @@ -133,7 +129,6 @@ protected ErrorResponse handleMissingServletRequestParameterException(MissingSer

/**
* 잘못된 URL 호출 시
* @param e NoHandlerFoundException
* @return ResponseEntity<ErrorResponse>
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
Expand All @@ -145,7 +140,6 @@ protected ErrorResponse handleNoHandlerFoundException(NoHandlerFoundException e)

/**
* API 호출 시 데이터를 반환할 수 없는 경우
* @param e HttpMessageNotWritableException
* @return ResponseEntity<ErrorResponse>
*/
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
Expand All @@ -155,9 +149,9 @@ protected ErrorResponse handleHttpMessageNotWritableException(HttpMessageNotWrit
return ErrorResponse.of(ErrorCode.INTERNAL_SERVER_ERROR.getMessage());
}


/**
* NullPointerException이 발생한 경우
* @param e NullPointerException
* @return ResponseEntity<ErrorResponse>
*/
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ spring:
host: ${REDIS_HOST}
port: ${REDIS_PORT}

mvc:
throw-exception-if-no-handler-found: true
web:
resources:
add-mappings: false

# security:
# oauth2:
# client:
Expand Down Expand Up @@ -138,6 +144,7 @@ spring:
generate-ddl: false
hibernate:
ddl-auto: none
show-sql: false

main:
allow-bean-definition-overriding: true
Expand All @@ -146,6 +153,12 @@ spring:
host: ${REDIS_HOST}
port: ${REDIS_PORT}

mvc:
throw-exception-if-no-handler-found: true
web:
resources:
add-mappings: false

springdoc:
default-consumes-media-type: application/json;charset=UTF-8
default-produces-media-type: application/json;charset=UTF-8
Expand Down

0 comments on commit 5e43fec

Please sign in to comment.