C.W.K.
Stream
Lesson 05 of 07 · published

Error Message

~9 min · protocol, errors

Level 0Poller
0 XP0/60 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Error 는 데이터, 예외 아냐

Protocol 의 error message 가 그냥 다른 message: typed envelope, machine-readable code, human-readable text. 클라 UI 가 code 를 동작 (toast, modal, redirect) 에 매핑. error format 이 public API 의 일부 — 한 번 픽, 유지.

여섯 표준 code

이 여섯 커버하면 REST 의 error 어휘 대부분 WebSocket 으로 옮겨와: invalid_message, unauthorized, forbidden, not_found, rate_limited, internal_error. 앱별 code 필요하면 추가 (room_full, session_expired) 근데 release 사이 stable 유지.

Code

Error envelope·json
{
  "type":    "error",
  "code":    "rate_limited",
  "message": "you're sending too fast, slow down",
  "details": {
    "retry_after": 5,
    "limit":       "20 messages/second"
  },
  "ref_id":  "abc-123"
}
표준 code·text
invalid_message   - message did not match envelope or schema
unauthorized      - missing or invalid auth
forbidden         - authenticated but not permitted
not_found         - referenced room/user/resource does not exist
rate_limited      - too many messages too fast
internal_error    - server-side bug or unexpected failure

External links

Exercise

Chat 앱에 6행 error code 표 정의. 각 code 마다 trigger 조건 (서버), user-facing message (UI), 클라쪽 동작 (toast / modal / redirect / silently retry) 적어. protocol spec 에 표로 문서화.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.