Conversation
Contributor
There was a problem hiding this comment.
Code Review
이번 풀 리퀘스트는 README.md와 validation-errors.md 문서에 에러 핸들링 가이드를 추가하여 사용자가 CargoValidationError를 처리하는 방법을 상세히 안내합니다. 리뷰를 통해 CargoFieldError의 field 타입을 실제 구현과 일치하도록 string으로 수정하고, README.md에도 에러 전파를 위한 next(err) 호출 관련 주의사항을 추가하여 문서 간의 일관성을 확보하도록 권장하였습니다.
| | Property | Type | Description | | ||
| |---|---|---| | ||
| | `name` | `string` | Always `'CargoFieldError'` | | ||
| | `field` | `string \| symbol` | The name of the field that failed | |
Contributor
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
TypeScript 스펙이 string | symbol인데 express-cargo에서는 이 형식 그대로 저장하고 있습니다.
(type.ts의 114번째 줄: return new CargoFieldError(this.propertyKey, message))
그래서 Symbol로 들어오는 경우에는 Symbol로 에러에 보여주고 있어서 field: string | symbol 타입으로 작성하는게 더 정확하다고 생각했습니다.
laggu
previously approved these changes
Apr 17, 2026
Member
|
docs 도 작업 부탁드려요 |
yuchem2
approved these changes
Apr 18, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
validation-errors.md와 README의 Error Handling 섹션에 에러 가이드 작성햇습니다.
추가한 내용
에러 타입 설명
CargoValidationError에는 errors 배열이 있고 각 배열 항목은 CargoFieldError인데
field어떤 필드인지와 message-> 왜 실패했는지를 담고 있다는 걸 표로 정리
사용법 두 가지
setCargoErrorHandler: 앱 시작할 때 한 번 등록하면 모든 라우트에 자동 적용 (권장)
Express error middleware: 기존 Express 방식(app.use((err, req, res, next) => ...))으로 잡는 방법
두 방식 관계 설명
둘 다 쓰면 setCargoErrorHandler가 먼저 실행된다는 것 명시
여러 에러 동시 처리
필드 두 개가 동시에 실패하면 err.errors 배열에 두 개가 같이 담겨서 한 번에 응답할 수 있다는 예시
추가로 README의 e.name → e.message 버그를 수정 했습니다.