diff --git a/src/main/java/com/mpnp/baechelin/exception/ErrorCode.java b/src/main/java/com/mpnp/baechelin/exception/ErrorCode.java index db5e5f8..ea36380 100644 --- a/src/main/java/com/mpnp/baechelin/exception/ErrorCode.java +++ b/src/main/java/com/mpnp/baechelin/exception/ErrorCode.java @@ -19,7 +19,9 @@ public enum ErrorCode { ALREADY_LOGIN_ACCOUNT(400, "E-ALA400","다른 계정으로 로그인 되었습니다."), API_LOAD_FAILURE(500, "E-ALF500", "API 로딩에 실패하였습니다."), - API_NO_RESULT(500, "E-ALF500", "API 결과가 존재하지 않습니다."); + API_NO_RESULT(500, "E-ALF500", "API 결과가 존재하지 않습니다."), + + NULL_POINTER_EXCEPTION(500, "E-NPE500", "NULL값이 들어올 수 없습니다."); private final int status; private final String code; diff --git a/src/main/java/com/mpnp/baechelin/exception/ErrorResponse.java b/src/main/java/com/mpnp/baechelin/exception/ErrorResponse.java index 265af2e..3b50255 100644 --- a/src/main/java/com/mpnp/baechelin/exception/ErrorResponse.java +++ b/src/main/java/com/mpnp/baechelin/exception/ErrorResponse.java @@ -1,7 +1,9 @@ package com.mpnp.baechelin.exception; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; import org.springframework.http.ResponseEntity; import java.time.LocalDateTime; diff --git a/src/main/java/com/mpnp/baechelin/exception/GlobalExceptionHandler.java b/src/main/java/com/mpnp/baechelin/exception/GlobalExceptionHandler.java index fd6229d..c5c1cfc 100644 --- a/src/main/java/com/mpnp/baechelin/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/mpnp/baechelin/exception/GlobalExceptionHandler.java @@ -19,6 +19,12 @@ protected ResponseEntity handleCustomException(CustomException e) return ErrorResponse.toResponseEntity(e.getErrorCode()); } + @ExceptionHandler(value = NullPointerException.class) + protected ResponseEntity handleNullPointerException(NullPointerException e) { + log.error("Null값이 들어올 수 없습니다."); + return ErrorResponse.toResponseEntity(ErrorCode.NULL_POINTER_EXCEPTION); + } + @ExceptionHandler(value = SignatureException.class) protected ResponseEntity handleSignatureException(SignatureException e) { log.error("잘못된 JWT 서명입니다.");