Skip to content

docs: add error handler usage guide to README and docs#217

Merged
dami0806 merged 3 commits intodevelopfrom
CARGO-368
Apr 19, 2026
Merged

docs: add error handler usage guide to README and docs#217
dami0806 merged 3 commits intodevelopfrom
CARGO-368

Conversation

@dami0806
Copy link
Copy Markdown
Contributor

validation-errors.md와 README의 Error Handling 섹션에 에러 가이드 작성햇습니다.

추가한 내용

  1. 에러 타입 설명
    CargoValidationError에는 errors 배열이 있고 각 배열 항목은 CargoFieldError인데
    field어떤 필드인지와 message-> 왜 실패했는지를 담고 있다는 걸 표로 정리

  2. 사용법 두 가지
    setCargoErrorHandler: 앱 시작할 때 한 번 등록하면 모든 라우트에 자동 적용 (권장)
    Express error middleware: 기존 Express 방식(app.use((err, req, res, next) => ...))으로 잡는 방법

  3. 두 방식 관계 설명
    둘 다 쓰면 setCargoErrorHandler가 먼저 실행된다는 것 명시

  4. 여러 에러 동시 처리
    필드 두 개가 동시에 실패하면 err.errors 배열에 두 개가 같이 담겨서 한 번에 응답할 수 있다는 예시

추가로 README의 e.name → e.message 버그를 수정 했습니다.

@dami0806 dami0806 self-assigned this Apr 16, 2026
@auto-assign auto-assign Bot requested review from laggu, sezeme and yuchem2 April 16, 2026 08:51
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

CargoFieldErrorfield 속성은 실제 구현(binding.ts)에서 Symboldescription을 사용하거나 String()으로 변환되어 항상 문자열로 처리됩니다. 따라서 타입을 string으로 명시하는 것이 더 정확합니다.

Suggested change
| `field` | `string \| symbol` | The name of the field that failed |
| `field` | `string` | The name of the field that failed |

Copy link
Copy Markdown
Contributor Author

@dami0806 dami0806 Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript 스펙이 string | symbol인데 express-cargo에서는 이 형식 그대로 저장하고 있습니다.
(type.ts의 114번째 줄: return new CargoFieldError(this.propertyKey, message))

그래서 Symbol로 들어오는 경우에는 Symbol로 에러에 보여주고 있어서 field: string | symbol 타입으로 작성하는게 더 정확하다고 생각했습니다.

Comment thread README.md Outdated
laggu
laggu previously approved these changes Apr 17, 2026
@laggu
Copy link
Copy Markdown
Member

laggu commented Apr 17, 2026

docs 도 작업 부탁드려요

Copy link
Copy Markdown
Member

@yuchem2 yuchem2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 언어 문서도 필요할 것 같아요!

@dami0806 dami0806 merged commit afb6efa into develop Apr 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants