에러 응답
#HTTP 상태 코드
| 코드 | 의미 |
|---|---|
200 | 성공 |
400 | 쿼리 검증 실패, 또는 요청 내용이 서로 맞지 않음 |
404 | 자원이 존재하지 않음 |
429 | 레이트 리밋 초과 |
500 | 서버 오류 |
#응답 envelope
{
"statusCode": 400,
"error": "Bad Request",
"message": [
"outcomeId must be a string",
"outcomeId should not be empty"
]
}| 필드 | 설명 |
|---|---|
statusCode | HTTP 상태와 동일한 숫자 |
error | 짧은 사람용 라벨 ("Bad Request", "Not Found"). 429 와 500 에는 없습니다. |
message | string 또는 string[]. 쿼리 검증 실패는 배열이고, 핸들러가 직접 내는 에러(호가창의 outcomeId 누락, 존재하지 않는 시장)는 문자열 하나입니다. |
message 가 배열일 수 있다는 점
요청 검증기의 검증 실패는 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 is required" |
시계열 가격에서 outcomeId 누락 | 400 + ["outcomeId must be a string", "outcomeId should not be empty"] |
| 잘못된 enum 값 | 400 + ["status must be one of the following values: ACTIVE, RESOLVED, CANCELLED"] |
| 정의되지 않은 쿼리 파라미터 | 400 + ["property foo should not exist"] |
| 시장이 없음 | 404 + "Market not found: <id or slug>" |
| 결과가 없음 | 404 + "Outcome not found" |
| 다른 시장의 결과 | 400 + "Outcome does not belong to this market" |
| Rate limit | 429 + "ThrottlerException: Too Many Requests" (error 필드 없음) |
#Rate limit
공개 엔드포인트는 IP 별로 레이트 리밋이 적용됩니다. 현재 수치는 요청 제한 을 참고하세요.
429 를 받으면 short backoff (수 초) 후 재시도하세요. 지속적으로 막힌다면 Retry-After 헤더를 참고합니다.
#다음
- 페이지네이션 — 정상 응답의 list envelope
- REST → Markets — 실제 엔드포인트
이 페이지가 도움이 되었나요?