- API error: the API answered with an error status, such as
404or422. The body is a problem document with acode, atitle, thestatus, and usually adetailand arequestId. - Transport error: no response arrived, because of a network failure or a timeout.
- Response error: a successful response that the client could not read as the contract describes, for example a status the contract does not list or a body of the wrong shape.
Error types
- TypeScript
- Python
- Rust
Every error the client throws extends
PhotonError, which has operationId
and requestId when they are known.error.body is typed unknown: the client does not check error bodies against
the contract. The contract’s error types are exported for reference, per
operation, such as GetProjectErrors.Handle an API error
Match on the problem’scode (or its type URI). Both are stable. Do not match
on title or detail: they are written for people and can change. Every code
is listed in the problem catalog.
This example asks for a project that does not exist, so the API answers 404
with PROJECT_NOT_FOUND:
Request IDs
Every API response has anX-Request-ID header that identifies that HTTP
attempt, and problem documents usually repeat it as requestId. Log it, and
quote it when you contact Photon support about a failed call. When the client
retried a call, the request ID is the one from the last attempt.
- TypeScript:
error.requestIdonApiErrorandResponseValidationError. - Python:
error.request_idonApiErrorandResponseValidationError. - Rust:
response.headers().get("x-request-id")on theResponseValueinError::Api,headersinError::UnexpectedStatusandError::Decode, or the problem’srequest_idfield.