Skip to content

Commit

Permalink
#33 [Update] NullPointerException 예외 처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna-Jin committed Jul 19, 2022
1 parent a04c748 commit fe4379b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/com/mpnp/baechelin/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/mpnp/baechelin/exception/ErrorResponse.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ protected ResponseEntity<ErrorResponse> handleCustomException(CustomException e)
return ErrorResponse.toResponseEntity(e.getErrorCode());
}

@ExceptionHandler(value = NullPointerException.class)
protected ResponseEntity<ErrorResponse> handleNullPointerException(NullPointerException e) {
log.error("Null값이 들어올 수 없습니다.");
return ErrorResponse.toResponseEntity(ErrorCode.NULL_POINTER_EXCEPTION);
}

@ExceptionHandler(value = SignatureException.class)
protected ResponseEntity<ErrorResponse> handleSignatureException(SignatureException e) {
log.error("잘못된 JWT 서명입니다.");
Expand Down

0 comments on commit fe4379b

Please sign in to comment.