-
Notifications
You must be signed in to change notification settings - Fork 2
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] global response 추가 #13
Conversation
- enum 클래스로 구현 - INTERNAL_SERVER 추가
- CustomException 추가 - RuntimeException 경우 추가
…to KAN-18-feat/global
Test Results1 tests 1 ✅ 0s ⏱️ Results for commit 464c374. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global response 및 exception에 대하여 정말 잘 구현해주시고, 컨벤션도 잘 지켜주신 것 같습니다 👍 궁금한 점은 리뷰에 달아놓았습니다!
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum ErrorCode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AllArgsConstructor 와 @Getter 어노테이션을 사용한다면 코드가 간결해질 것 같아요
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.ourmenu.backend.global.exception.ErrorResponse; | ||
|
||
public class ApiResponse<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 @AllArgsConstructor 어노테이션을 사용할 수 있을 것 같아요
|
||
public class ApiUtil { | ||
|
||
private ApiUtil() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정적 유틸리티 클래스 구조를 잘 구현해주신 것 같아요. 유틸 클래스는 객체지향적 프로그래밍이 아니라는 문제점이 있는데, 이에 대한 의견과 Spirng Bean으로 등록하는 방법에 대해 어떻게 생각하시는지 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정적 유틸 클래스는 분명 OOP를 벗어난 영역입니다. 구현하면서도 정적 클래스를 최대한 지양하는게 맞다고 생각했습니다. ApiUtil은 ApiResponse을 반환하는 역활을 가지고 있습니다. 분명 객체가 할 수 있는 영역입니다. 다만 진행하고 있는 프로젝트에서의 ApiUtil은 모든 엔드포인트 종단점에서 호출되어야하고. 만약 객체로 선언한다라면 메인 도메인 로직에서 불필요한 객체 선언을 계속 해야한다는 점에서 유틸클래스로 구현하게 되었어요.
@Builder | ||
public record ErrorResponse(int status, String code, String message) { | ||
|
||
public static ErrorResponse of(ErrorCode errorCode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이와 같이 DTO에서 Response를 build하는 메소드를 정의해놓으면 Service 레이어의 코드가 간결해질 것 같네요! 👍👍
import lombok.Builder; | ||
|
||
@Builder | ||
public record ErrorResponse(int status, String code, String message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTO에서 record 클래스를 사용하는 방법 좋은 것 같아요
빠른 리뷰 반영 감사드리며 머지하겠습니다 :D |
✏️ 작업 개요
⛳ 작업 분류
🔨 작업 상세 내용
💡 생각해볼 문제
ex)
ERROR 11984 --- [backend] [nio-8080-exec-3] c.o.b.g.e.GlobalExceptionHandler : G500: 에러메세지