W1nd5pac's picture
Deploy 2026-05-20T07:09:24Z — 11e81c5 (code)
a8358d8 verified
raw
history blame contribute delete
798 Bytes
"""
Centralised error contract.
Every non-2xx response from the API has the same JSON shape so a
client (Vue SPA, curl, Postman, future mobile app) can rely on it.
"""
from __future__ import annotations
from typing import Any
from pydantic import BaseModel
class ErrorResponse(BaseModel):
error: str # short, stable identifier (snake_case)
detail: str # human readable
request_id: str | None = None
context: dict[str, Any] | None = None
# Canonical error identifiers — used as the `error` field. Adding new ones
# requires updating the OpenAPI docstring on the predict() endpoint too.
ERR_UPSTREAM_FAILURE = "upstream_failure"
ERR_INVALID_INPUT = "invalid_input"
ERR_MODEL_ERROR = "model_error"
ERR_INTERNAL = "internal_error"