-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/java/com/nice/petudio/global/exception/BadGatewayException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
|
||
public class BadGatewayException extends CustomException { | ||
|
||
public BadGatewayException(ErrorCode errorCode, String message) { | ||
super(errorCode, message); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/nice/petudio/global/exception/CustomException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CustomException extends RuntimeException { | ||
private final ErrorCode errorCode; | ||
|
||
public CustomException(ErrorCode errorCode, String message) { | ||
super(message); | ||
this.errorCode = errorCode; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/nice/petudio/global/exception/ForbiddenException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
|
||
public class ForbiddenException extends CustomException { | ||
|
||
public ForbiddenException(ErrorCode errorCode, String message) { | ||
super(errorCode, message); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/nice/petudio/global/exception/InternalServerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
|
||
public class InternalServerException extends CustomException { | ||
|
||
public InternalServerException(ErrorCode errorCode, String message) { | ||
super(errorCode, message); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/nice/petudio/global/exception/NotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
|
||
public class NotFoundException extends CustomException { | ||
|
||
public NotFoundException(ErrorCode errorCode, String message) { | ||
super(errorCode, message); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/nice/petudio/global/exception/UnauthorizedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
|
||
public class UnauthorizedException extends CustomException { | ||
|
||
public UnauthorizedException(ErrorCode errorCode, String message) { | ||
super(errorCode, message); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/nice/petudio/global/exception/ValidationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nice.petudio.global.exception; | ||
|
||
import com.nice.petudio.global.exception.error.ErrorCode; | ||
|
||
public class ValidationException extends CustomException { | ||
|
||
public ValidationException(ErrorCode errorCode, String message) { | ||
super(errorCode, message); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/nice/petudio/global/exception/error/ErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.nice.petudio.global.exception.error; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public enum ErrorCode { | ||
// Validation Exception | ||
VALIDATION_EXCEPTION("V001", "잘못된 요청입니다."), | ||
METHOD_NOT_ALLOWED_EXCEPTION("V002", "지원하지 않는 메소드입니다."), | ||
UNSUPPORTED_MEDIA_TYPE("V003", "허용하지 않는 미디어 타입입니다."), | ||
INVALID_TOKEN_EXCEPTION("V004", "잘못된 JWT 토큰 형식입니다."), | ||
|
||
// Unauthorized Exception | ||
UNAUTHORIZED_TOKEN_EXCEPTION("U001", "토큰이 존재하지 않거나 유효하지 않습니다. 다시 로그인 해주세요."), | ||
|
||
// Forbidden Exception | ||
FORBIDDEN_EXCEPTION("F001", "접근 권한이 존재하지 않습니다."), | ||
|
||
// NotFound Exception | ||
NOT_FOUND_EXCEPTION("N001", "존재하지 않는 요청입니다."), | ||
NOT_FOUND_MEMBER_EXCEPTION("N002", "탈퇴했거나 존재하지 않는 회원입니다."), | ||
NOT_FOUND_CONCEPT_EXCEPTION("N004", "존재하지 않는 컨셉입니다."), | ||
|
||
// Conflict Exception | ||
CONFLICT_EXCEPTION("C001", "이미 존재하는 데이터입니다."), | ||
CONFLICT_MEMBER_EXCEPTION("C002", "이미 해당 계정으로 회원가입이 되어있습니다.\n로그인 해주세요."), | ||
|
||
// Internal Server Exception | ||
INTERNAL_SERVER_EXCEPTION("I001", "서버 내부에서 에러가 발생하였습니다."), | ||
|
||
// Bad Gateway Exception | ||
BAD_GATEWAY_EXCEPTION("B001", "외부 연동 중 에러가 발생하였습니다."); | ||
|
||
|
||
private final String code; | ||
private final String message; | ||
} |