Error Handling — Proposed Guide
Planned API — Reference OnlyError Handling: Error handling should distinguish an invalid request from insufficient access, a missing resource and a temporary dependency failure. The…
Overview
Error handling should distinguish an invalid request from insufficient access, a missing resource and a temporary dependency failure. The same retry policy is not appropriate for all of these outcomes.
Key concepts
Use a stable error code for branching and a request identifier for investigation. Field-level details should describe invalid input without echoing credentials or private financial information.
Implementation considerations
Do not retry an unauthorized request indefinitely. Correct validation failures before retrying, and consult the operation-specific contract before retrying a write.
Proposed API behavior
GET /v1/expenses/exp_example_123 is an illustrative design for this topic. Path and field names may change before implementation. Access would require an authorized organization context and operation-specific permission; no public API or authorization grant is available here.
No additional request fields are illustrated; this is not a finalized contract.
Static example requests
# Proposed request text only; this reserved host is not a live API.
curl -X GET 'https://api.remizen.example/v1/expenses/exp_example_123' \
-H 'Authorization: Bearer YOUR_API_KEY'Fictional response example
Fictional documentation data only. No request was sent, record created, review performed, payment initiated or provider connection activated.
{
"data": [
{
"expense_id": "exp_example_123",
"id": "exp_example_123",
"organization_id": "org_example_123",
"merchant": "Example Office Supply",
"amount_minor": 12550,
"currency": "USD",
"status": "draft"
}
],
"pagination": {
"has_more": false,
"next_cursor": null
},
"meta": {
"request_id": "req_example_123",
"reference_only": true
}
}Illustrative error case
Review this failure case in context: Do not retry an unauthorized request indefinitely. Correct validation failures before retrying, and consult the operation-specific contract before retrying a write.
Synthetic diagnostic example. Human-readable messages must not be used as stable programmatic contracts.
{
"error": {
"code": "validation_error",
"message": "The proposed error handling operation requires review of its input or authorization.",
"request_id": "req_example_123"
}
}Proposed data types
| Name | Type | Description |
|---|---|---|
| expense_id | string | Stable fictional expense reference; not a secret and not evidence that a resource exists. |
| request_id | string | Stable fictional request reference; not a secret and not evidence that a resource exists. |
| error_code | string | Illustrative machine-readable error classification; final codes remain undecided. |