-
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.
* feat: 에러 코드 구현 * feat: 커스텀 예외 구현 * feat: 예외 응답 구현
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/com/depromeet/global/error/ErrorResponse.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,16 @@ | ||
package com.depromeet.global.error; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public record ErrorResponse( | ||
int status, | ||
String message, | ||
LocalDateTime timestamp | ||
) { | ||
|
||
public static ErrorResponse of(HttpStatus status, String message) { | ||
return new ErrorResponse(status.value(), message, LocalDateTime.now()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/depromeet/global/error/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,11 @@ | ||
package com.depromeet.global.error.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class CustomException extends RuntimeException { | ||
|
||
private final ErrorCode errorCode; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/depromeet/global/error/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,17 @@ | ||
package com.depromeet.global.error.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ErrorCode { | ||
|
||
SAMPLE_ERROR(HttpStatus.BAD_REQUEST, "Sample Error Message"), | ||
; | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
} |