Error codes
Photon answers errors with an RFC 9457 problem document. The type field is a link to one of these pages; the code field is the same value without the URL, and is the stable thing to match on.
{"type":"https://photon.agenticmarket.dev/errors/not_found","title":"not found","status":404,"code":"not_found"}| Code | Status | Meaning |
|---|---|---|
bad_request |
400 | The request was malformed: invalid JSON, a missing field, or a value the handler could not use. |
unauthorized |
401 | The request has no valid credentials. |
forbidden |
403 | The credentials are valid, but not allowed to do this. |
not_found |
404 | No route matches the path, or the resource does not exist. |
method_not_allowed |
405 | The path exists, but not for this HTTP method. |
conflict |
409 | The request conflicts with the current state of the resource. |
limit_exceeded |
413 | The request body is larger than the server accepts. |
unsupported_media_type |
415 | The body is not in a format the endpoint accepts. |
unprocessable |
422 | The request is well-formed but its content is not valid. |
too_many_requests |
429 | The client is sending requests faster than it is allowed to. |
too_many_headers |
431 | The request has more header fields than the server accepts. |
header_value_too_large |
431 | One header value is longer than the server accepts. |
canceled |
499 | The client closed the request before the server answered. |
internal_error |
500 | The server failed while handling the request. |
upstream_error |
502 | A service the server depends on, such as a model provider, failed. |
unavailable |
503 | The server cannot handle the request right now. |
server_at_capacity |
503 | The server is handling as many requests as it is configured to allow. |
too_many_streams |
503 | The server has as many open streams as its memory budget allows. |
timeout |
504 | The server, or a service it called, did not finish in time. |
Your own handlers can return any of these with the constructors in photonerr, or define your own code with a &photonerr.Error{Status: ..., Code: ..., Message: ...} literal.