Skip to content

Commit 1cfeaa3

Browse files
committed
feat: custom exception 정의
1 parent 72517a8 commit 1cfeaa3

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.loopers.support.error;
2+
3+
import lombok.Getter;
4+
5+
@Getter
6+
public class CoreException extends RuntimeException {
7+
private final ErrorType errorType;
8+
private final String customMessage;
9+
10+
public CoreException(ErrorType errorType) {
11+
this(errorType, null);
12+
}
13+
14+
public CoreException(ErrorType errorType, String customMessage) {
15+
super(customMessage != null ? customMessage : errorType.getMessage());
16+
this.errorType = errorType;
17+
this.customMessage = customMessage;
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.loopers.support.error;
2+
3+
import lombok.Getter;
4+
import lombok.RequiredArgsConstructor;
5+
import org.springframework.http.HttpStatus;
6+
7+
@Getter
8+
@RequiredArgsConstructor
9+
public enum ErrorType {
10+
/** 범용 에러 */
11+
INTERNAL_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), "일시적인 오류가 발생했습니다."),
12+
BAD_REQUEST(HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST.getReasonPhrase(), "잘못된 요청입니다."),
13+
NOT_FOUND(HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND.getReasonPhrase(), "존재하지 않는 요청입니다."),
14+
CONFLICT(HttpStatus.CONFLICT, HttpStatus.CONFLICT.getReasonPhrase(), "이미 존재하는 리소스입니다.");
15+
16+
private final HttpStatus status;
17+
private final String code;
18+
private final String message;
19+
}

0 commit comments

Comments
 (0)