Skip to main content

에러 응답

#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"
  ]
}
필드설명
statusCodeHTTP 상태와 동일한 숫자
error짧은 사람용 라벨 ("Bad Request", "Not Found")
messagestring 또는 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"]
잘못된 enum400 + ["status must be one of: ACTIVE, ..."]
시장이 없음404 + "Market not found"
Rate limit429 + "ThrottlerException: Too Many Requests"

#Rate limit

공개 엔드포인트는 애플리케이션 레벨에서 IP 별로 레이트 리밋이 적용됩니다. 현재 수치는 요청 제한 을 참고하세요.

429 를 받으면 short backoff (수 초) 후 재시도하세요. 지속적으로 막힌다면 Retry-After 헤더를 참고합니다.

#다음

이 페이지가 도움이 되었나요?