-
Notifications
You must be signed in to change notification settings - Fork 0
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
YW2-237 feat: 공통 Response 및 ControllerAdvice 정의 #5
base: main
Are you sure you want to change the base?
Conversation
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.
LGTM 👍
코멘트 확인 부탁드려요~!
in 4000 until 4100 -> HttpStatus.BAD_REQUEST | ||
in 4100 until 4200 -> HttpStatus.NOT_FOUND | ||
in 5000 until 5100 -> HttpStatus.INTERNAL_SERVER_ERROR | ||
else -> HttpStatus.INTERNAL_SERVER_ERROR |
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.
에러코드 범위 확인했습니다~!
if(activeProfilesResolver.isPrd()){ | ||
return null | ||
} | ||
return this.stackTraceToString() |
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.
오호 Prod 환경에서는 스택트레이스를 노출하지 않는군요,,
val data: T? = null, | ||
val error: ErrorResponse? = null, | ||
val debug: String? = null | ||
){ |
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.
이 부분 SealedInterface 적용해보는건 어떨까요?
sealed interface ApiResponse<T> {
val result: ResponseType
data class Success<T>(
val data: T?
) : ApiResponse<T> {
override val result = ResponseType.SUCCESS
}
data class Error<T>(
val error: ErrorResponse? = null,
val debug: String? = null
) : ApiResponse<T> {
override val result = ResponseType.ERROR
}
}
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.
sealed interface를 잘 사용해볼 버릇을 안해봐서 정확한 사용처? 에 대해서 아직 와닿지않는 것 같습니다 ㅎㅎ..
사실 사용해본 것도 enum과 같이 when절 -> else 미정의시 컴파일 타임에 에러 잡기위한 용도 정도밖에 없었어서요
혹시 sealed 키워드 (클래스, 인터페이스 포함) 를 사용하시는 기준이 있을까요?
그와 더불어서, 제안해주신 코드 대로 진행한다면 성공때와 실패때의 응답이 달라질 것 같은데 혹시맞을까요?
클라이언트 측에서는 어차피 하나의 모델로 대응가능할 것 같긴합니다만
data class ErrorResponse( | ||
val code: Int, | ||
val message: String, | ||
val data: String? = null |
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.
ErrorResponse의 data 부는 어떤 값들이 들어가게 될까요?
특별한 값이 아니라면, DangleExeption만으로도 표현이 가능할 것 같아서요!
(message는 사용자에게 직접 노출되는 에러메시지)
data class Error<T>(
val code: String,
val message: String,
val debug: String? = null,
) : ApiResponse<T> {
override val result = ResponseType.ERROR
}
ApiResponse.Error(
error = dangleException.errorCode.value,
message = dangleException.errorCode.message,
debug = dangleException.debug,
)
추가질문) 저희 클라이언트에서 아래 ResponseType 값을 바라보고 있나요? enum class ResponseType{
SUCCESS, ERROR
} |
지금은 그냥 200으로 분기하고 있는걸로 알고있습니다. |
🎯 작업 내역
📜 Jira 티켓
https://yapp22-web2.atlassian.net/browse/YW2-237
📁 영향범위 (모듈)
📒 SQL (DDL 변경사항 있는 경우만)
---
Resolves: # See also: #