Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 커스텀 예외 및 에러 코드/응답 구현 #19

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/com/depromeet/global/error/ErrorResponse.java
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());
}
}
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;
}
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;
}
Loading