-
Notifications
You must be signed in to change notification settings - Fork 3
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
6 changed files
with
61 additions
and
24 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
9 changes: 9 additions & 0 deletions
9
Match-Common/src/main/java/com/example/matchcommon/exception/IllegalArgumentException.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,9 @@ | ||
package com.example.matchcommon.exception; | ||
|
||
import com.example.matchcommon.exception.errorcode.BaseErrorCode; | ||
|
||
public class IllegalArgumentException extends BaseException{ | ||
public IllegalArgumentException(BaseErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Match-Common/src/main/java/com/example/matchcommon/exception/errorcode/FilterErrorCode.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,45 @@ | ||
package com.example.matchcommon.exception.errorcode; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Objects; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import com.example.matchcommon.annotation.ExplainError; | ||
import com.example.matchcommon.dto.ErrorReason; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum FilterErrorCode implements BaseErrorCode{ | ||
|
||
/** | ||
* 잘못된 요청 | ||
*/ | ||
NOT_EXISTS_FILTER(HttpStatus.BAD_REQUEST, "FILTER_001", "필터값이 존재하지 않습니다."); | ||
|
||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
|
||
@Override | ||
public ErrorReason getErrorReason() { | ||
return ErrorReason.builder().message(message).code(code).isSuccess(false).build(); | ||
} | ||
|
||
@Override | ||
public String getExplainError() throws NoSuchFieldException { | ||
Field field = this.getClass().getField(this.name()); | ||
ExplainError annotation = field.getAnnotation(ExplainError.class); | ||
return Objects.nonNull(annotation) ? annotation.value() : this.getMessage(); | ||
} | ||
|
||
@Override | ||
public ErrorReason getErrorReasonHttpStatus(){ | ||
return ErrorReason.builder().message(message).code(code).isSuccess(false).httpStatus(httpStatus).build(); | ||
} | ||
} |
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