DocsError Handling & Format

Error Handling & Format

The Charged API follows strict conventions for error handling, ensuring that developers interacting with it receive clear, actionable feedback without exposing sensitive internal workings.

We employ a standard JSON response envelope for all failures. Rather than dumping a raw stack trace or generic '500 Internal Server Error' message, the system parses the exception and returns a structured object containing a 'success' boolean, an 'error' code string, and a 'message' intended to be read by humans.

This approach not only prevents data leakage but also allows dashboard clients to map specific error codes to localized translation strings gracefully. Rate limit violations automatically trigger a 429 status code with a 'RATE_LIMIT_EXCEEDED' error payload.