-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 예외 응답값에 예외 코드 추가 Co-authored-by: hamcheeseburger <[email protected]> Co-authored-by: yangdongjue5510 <[email protected]> * refactor: 예외 클래스 명 수정 Co-authored-by: hamcheeseburger <[email protected]> Co-authored-by: yangdongjue5510 <[email protected]> Co-authored-by: hamcheeseburger <[email protected]> Co-authored-by: yangdongjue5510 <[email protected]>
- Loading branch information
1 parent
dfea906
commit 18e6863
Showing
45 changed files
with
236 additions
and
96 deletions.
There are no files selected for viewing
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
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
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
14 changes: 9 additions & 5 deletions
14
backend/src/main/java/com/woowacourse/f12/dto/response/ExceptionResponse.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 |
---|---|---|
@@ -1,24 +1,28 @@ | ||
package com.woowacourse.f12.dto.response; | ||
|
||
import com.woowacourse.f12.exception.CustomException; | ||
import com.woowacourse.f12.exception.ErrorCode; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ExceptionResponse { | ||
|
||
private String message; | ||
private ErrorCode errorCode; | ||
|
||
private ExceptionResponse() { | ||
} | ||
|
||
private ExceptionResponse(final String message) { | ||
private ExceptionResponse(final String message, final ErrorCode errorCode) { | ||
this.message = message; | ||
this.errorCode = errorCode; | ||
} | ||
|
||
public static ExceptionResponse from(final Exception e) { | ||
return new ExceptionResponse(e.getMessage()); | ||
public static ExceptionResponse from(final CustomException e) { | ||
return new ExceptionResponse(e.getMessage(), e.getErrorCode()); | ||
} | ||
|
||
public static ExceptionResponse from(final String message) { | ||
return new ExceptionResponse(message); | ||
public static ExceptionResponse from(final String message, final ErrorCode errorCode) { | ||
return new ExceptionResponse(message, errorCode); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/com/woowacourse/f12/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,15 @@ | ||
package com.woowacourse.f12.exception; | ||
|
||
public class CustomException extends RuntimeException { | ||
|
||
private final ErrorCode errorCode; | ||
|
||
public CustomException(final String message, final ErrorCode errorCode) { | ||
super(message); | ||
this.errorCode = errorCode; | ||
} | ||
|
||
public ErrorCode getErrorCode() { | ||
return errorCode; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
backend/src/main/java/com/woowacourse/f12/exception/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,35 @@ | ||
package com.woowacourse.f12.exception; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
public enum ErrorCode { | ||
|
||
INVALID_SEARCH_PARAM("40000"), | ||
INVALID_REQUEST_BODY("40001"), | ||
INVALID_TOKEN("40002"), | ||
DUPLICATED_CONTENT("40003"), | ||
BLANK_CONTENT("40004"), | ||
NOT_ENOUGH_DATA("40005"), | ||
|
||
TOKEN_NOT_EXISTS("40100"), | ||
TOKEN_EXPIRED("400101"), | ||
TOKEN_INVALID("400102"), | ||
|
||
PERMISSION_DENIED("40300"), | ||
|
||
DATA_NOT_FOUND("40400"), | ||
|
||
INTERNAL_SERVER_ERROR("50000"), | ||
EXTERNAL_SERVER_ERROR("50001"); | ||
|
||
private final String value; | ||
|
||
ErrorCode(final String value) { | ||
this.value = value; | ||
} | ||
|
||
@JsonValue | ||
public String getValue() { | ||
return value; | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...src/main/java/com/woowacourse/f12/exception/badrequest/AlreadyWrittenReviewException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.DUPLICATED_CONTENT; | ||
|
||
public class AlreadyWrittenReviewException extends InvalidValueException { | ||
|
||
public AlreadyWrittenReviewException() { | ||
super("해당 제품에 대해 이미 리뷰가 작성되어 있습니다."); | ||
super("해당 제품에 대해 이미 리뷰가 작성되어 있습니다.", DUPLICATED_CONTENT); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
backend/src/main/java/com/woowacourse/f12/exception/badrequest/BlankContentException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.BLANK_CONTENT; | ||
|
||
public class BlankContentException extends InvalidValueException { | ||
|
||
public BlankContentException() { | ||
super("리뷰 내용은 공백이 될 수 없습니다."); | ||
super("리뷰 내용은 공백이 될 수 없습니다.", BLANK_CONTENT); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...d/src/main/java/com/woowacourse/f12/exception/badrequest/InvalidCareerLevelException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_SEARCH_PARAM; | ||
|
||
public class InvalidCareerLevelException extends InvalidValueException { | ||
|
||
public InvalidCareerLevelException() { | ||
super("올바르지 않은 연차 입력입니다."); | ||
super("올바르지 않은 연차 입력입니다.", INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...src/main/java/com/woowacourse/f12/exception/badrequest/InvalidCategoryValueException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_SEARCH_PARAM; | ||
|
||
public class InvalidCategoryValueException extends InvalidValueException { | ||
|
||
public InvalidCategoryValueException() { | ||
super("잘못된 카테고리입니다."); | ||
super("잘못된 카테고리입니다.", INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...src/main/java/com/woowacourse/f12/exception/badrequest/InvalidContentLengthException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_REQUEST_BODY; | ||
|
||
public class InvalidContentLengthException extends InvalidValueException { | ||
|
||
public InvalidContentLengthException(final int maxLength) { | ||
super("내용의 길이는 " + maxLength + "자 이하 여야 합니다."); | ||
super("내용의 길이는 " + maxLength + "자 이하 여야 합니다.", INVALID_REQUEST_BODY); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...d/src/main/java/com/woowacourse/f12/exception/badrequest/InvalidGitHubLoginException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_SEARCH_PARAM; | ||
|
||
public class InvalidGitHubLoginException extends InvalidValueException { | ||
|
||
public InvalidGitHubLoginException() { | ||
super("잘못된 GitHub 로그인 요청입니다."); | ||
super("잘못된 GitHub 로그인 요청입니다.", INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
backend/src/main/java/com/woowacourse/f12/exception/badrequest/InvalidJobTypeException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import com.woowacourse.f12.exception.ErrorCode; | ||
|
||
public class InvalidJobTypeException extends InvalidValueException { | ||
|
||
public InvalidJobTypeException() { | ||
super("올바르지 않은 직군 입력입니다."); | ||
super("올바르지 않은 직군 입력입니다.", ErrorCode.INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
.../main/java/com/woowacourse/f12/exception/badrequest/InvalidPageNumberFormatException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_SEARCH_PARAM; | ||
|
||
public class InvalidPageNumberFormatException extends InvalidValueException { | ||
|
||
public InvalidPageNumberFormatException() { | ||
super("페이지 번호는 숫자 형식이여야 합니다."); | ||
super("페이지 번호는 숫자 형식이여야 합니다.", INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
backend/src/main/java/com/woowacourse/f12/exception/badrequest/InvalidPageSizeException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_SEARCH_PARAM; | ||
|
||
public class InvalidPageSizeException extends InvalidValueException { | ||
|
||
public InvalidPageSizeException(int maxSize) { | ||
super("페이지의 크기는" + maxSize + "이하여야 합니다."); | ||
super("페이지의 크기는" + maxSize + "이하여야 합니다.", INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...rc/main/java/com/woowacourse/f12/exception/badrequest/InvalidPageSizeFormatException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_SEARCH_PARAM; | ||
|
||
public class InvalidPageSizeFormatException extends InvalidValueException { | ||
|
||
public InvalidPageSizeFormatException() { | ||
super("패이지 크기는 숫자 형식이어야 합니다."); | ||
super("패이지 크기는 숫자 형식이어야 합니다.", INVALID_SEARCH_PARAM); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...c/main/java/com/woowacourse/f12/exception/badrequest/InvalidProfileArgumentException.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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
|
||
import static com.woowacourse.f12.exception.ErrorCode.NOT_ENOUGH_DATA; | ||
|
||
public class InvalidProfileArgumentException extends InvalidValueException { | ||
|
||
public InvalidProfileArgumentException() { | ||
super("추가 정보가 등록되지 않았습니다."); | ||
super("추가 정보가 등록되지 않았습니다.", NOT_ENOUGH_DATA); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...rc/main/java/com/woowacourse/f12/exception/badrequest/InvalidProfileProductException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_REQUEST_BODY; | ||
|
||
public class InvalidProfileProductException extends InvalidValueException { | ||
|
||
public InvalidProfileProductException() { | ||
super("유효하지 않은 대표 장비 수정 요청입니다."); | ||
super("유효하지 않은 대표 장비 수정 요청입니다.", INVALID_REQUEST_BODY); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...d/src/main/java/com/woowacourse/f12/exception/badrequest/InvalidRatingValueException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.INVALID_REQUEST_BODY; | ||
|
||
public class InvalidRatingValueException extends InvalidValueException { | ||
|
||
public InvalidRatingValueException() { | ||
super("평점은 1에서 5 사이여야 합니다."); | ||
super("평점은 1에서 5 사이여야 합니다.", INVALID_REQUEST_BODY); | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
backend/src/main/java/com/woowacourse/f12/exception/badrequest/InvalidValueException.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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.woowacourse.f12.exception.badrequest; | ||
|
||
public class InvalidValueException extends RuntimeException { | ||
import com.woowacourse.f12.exception.CustomException; | ||
import com.woowacourse.f12.exception.ErrorCode; | ||
|
||
public InvalidValueException(final String message) { | ||
super(message); | ||
public class InvalidValueException extends CustomException { | ||
|
||
public InvalidValueException(final String message, final ErrorCode errorCode) { | ||
super(message, errorCode); | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
backend/src/main/java/com/woowacourse/f12/exception/forbidden/ForbiddenMemberException.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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.woowacourse.f12.exception.forbidden; | ||
|
||
public class ForbiddenMemberException extends RuntimeException { | ||
import com.woowacourse.f12.exception.CustomException; | ||
import com.woowacourse.f12.exception.ErrorCode; | ||
|
||
public ForbiddenMemberException(final String message) { | ||
super(message); | ||
public class ForbiddenMemberException extends CustomException { | ||
|
||
public ForbiddenMemberException(final String message, final ErrorCode errorCode) { | ||
super(message, errorCode); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
backend/src/main/java/com/woowacourse/f12/exception/forbidden/NotAuthorException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.forbidden; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.PERMISSION_DENIED; | ||
|
||
public class NotAuthorException extends ForbiddenMemberException { | ||
|
||
public NotAuthorException() { | ||
super("리뷰의 작성자가 아닙니다."); | ||
super("리뷰의 작성자가 아닙니다.", PERMISSION_DENIED); | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
...d/src/main/java/com/woowacourse/f12/exception/internalserver/ExternalServerException.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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.woowacourse.f12.exception.internalserver; | ||
|
||
public class ExternalServerException extends RuntimeException { | ||
import com.woowacourse.f12.exception.CustomException; | ||
import com.woowacourse.f12.exception.ErrorCode; | ||
|
||
public ExternalServerException(final String message) { | ||
super(message); | ||
public class ExternalServerException extends CustomException { | ||
|
||
public ExternalServerException(final String message, final ErrorCode errorCode) { | ||
super(message, errorCode); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...end/src/main/java/com/woowacourse/f12/exception/internalserver/GitHubServerException.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.woowacourse.f12.exception.internalserver; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.EXTERNAL_SERVER_ERROR; | ||
|
||
public class GitHubServerException extends ExternalServerException { | ||
|
||
public GitHubServerException() { | ||
super("GitHub 서버에 문제가 있습니다."); | ||
super("GitHub 서버에 문제가 있습니다.", EXTERNAL_SERVER_ERROR); | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
.../src/main/java/com/woowacourse/f12/exception/notfound/InventoryItemNotFoundException.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...c/main/java/com/woowacourse/f12/exception/notfound/InventoryProductNotFoundException.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.woowacourse.f12.exception.notfound; | ||
|
||
import static com.woowacourse.f12.exception.ErrorCode.DATA_NOT_FOUND; | ||
|
||
public class InventoryProductNotFoundException extends NotFoundException { | ||
|
||
public InventoryProductNotFoundException() { | ||
super("등록 장비를 찾을 수 없습니다.", DATA_NOT_FOUND); | ||
} | ||
} |
Oops, something went wrong.