GET Error Codes
Last updated
Last updated
Paths
GET /error_codes
— returns all exposed error codes.
GET /error_codes/{error_code}
— returns the message for one specific code, or 404 if not found/blacklisted.
Example Query:
See this for more information about error codes.
Imports
ErrorCodes
is your master map of all possible error‐code → message entries.
ErrorCodeBlackList
lists codes you don’t want to expose via the public API.
GET /error_codes
Filters out any blacklisted codes, then returns the rest as a plain dict.
GET /error_codes/{error_code}
Looks up the message via ErrorCodes.get(error_code)
.
If missing or blacklisted, raises an ErrorCodeResponse(404)
.
Otherwise returns { error_code: message }
.
Define the Error Codes
Create the Response Schema
Define an Exception (example)
Add FastAPI Routes
In your common_router
, register the two @common_router.get
endpoints exactly as above.
Import ErrorCodes
, ErrorCodeBlackList
, ErrorCodeResponse
, and ErrorCodeResponseSchema
.