에러 응답
#HTTP 상태 코드
| 코드 | 의미 |
|---|---|
200 | 성공 |
201 | 자원 생성됨 |
400 | 요청 본문 / 쿼리 검증 실패 |
404 | 자원이 존재하지 않음 |
429 | 레이트 리밋 초과 |
500 | 서버 오류 |
#응답 envelope
{
"statusCode": 400,
"error": "Bad Request",
"message": [
"outcomeId must be a string",
"side must be one of: BUY, SELL"
]
}| 필드 | 설명 |
|---|---|
statusCode | HTTP 상태와 동일한 숫자 |
error | 짧은 사람용 라벨 ("Bad Request", "Not Found") |
message | string 또는 string[]. 검증 실패는 항상 배열. |
message 가 배열일 수 있다는 점
NestJS ValidationPipe 의 검증 실패는 항상 message: string[] 로 옵니다. 단순히 error.message 를 한 줄로 보여주면 안 되고, 배열의 각 원소를 별도로 렌더링하세요.
#클라이언트에서 처리하는 패턴
type ApiError = {
statusCode: number;
error: string;
message: string | string[];
};
async function call() {
const res = await fetch(url, init);
if (!res.ok) {
const err = (await res.json()) as ApiError;
const messages = Array.isArray(err.message) ? err.message : [err.message];
throw new Error(messages.join('\n'));
}
return res.json();
}#자주 만나는 시나리오
| 상황 | 응답 |
|---|---|
outcomeId 누락 | 400 + ["outcomeId should not be empty"] |
| 잘못된 enum | 400 + ["status must be one of: ACTIVE, ..."] |
| 시장이 없음 | 404 + "Market not found" |
| Rate limit | 429 + "ThrottlerException: Too Many Requests" |
#Rate limit
공개 엔드포인트는 애플리케이션 레벨에서 IP 별로 레이트 리밋이 적용됩니다. 현재 수치는 요청 제한 을 참고하세요.
429 를 받으면 short backoff (수 초) 후 재시도하세요. 지속적으로 막힌다면 Retry-After 헤더를 참고합니다.
#다음
- 페이지네이션 — 정상 응답의 list envelope
- REST → Markets — 실제 엔드포인트
이 페이지가 도움이 되었나요?