Documentation
¶
Overview ¶
Package httperr centralises the mapping from UniRate client errors to an HTTP status code and a JSON-serialisable error body. All three framework adapters (gin, echo, fiber) share this logic so error mapping stays identical across them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Body ¶
Body is the JSON error envelope returned to clients.
func Map ¶
Map inspects a UniRate client error and returns the HTTP status code and the JSON body to emit. It never returns a zero status: unclassified errors map to 500.
The mapping follows the canonical spec:
400 -> ErrInvalidDate "Invalid request parameters" 401 -> ErrAuthentication "Missing or invalid API key" 403 -> APIError(403) "Endpoint requires a Pro subscription" 404 -> ErrInvalidCurrency "Currency not found or no data available" 429 -> ErrRateLimit "Rate limit exceeded" 503 -> APIError(503) "Service unavailable" other APIError pass through its status network / unknown 500 "Internal server error"
Click to show internal directories.
Click to hide internal directories.