Expand description
Standard API error types for all api-bones services.
All services serialize errors into ApiError before sending an HTTP
response. The wire format conforms to
RFC 9457 — Problem Details for HTTP APIs:
{
"type": "urn:api-bones:error:resource-not-found",
"title": "Resource Not Found",
"status": 404,
"detail": "Booking 123 not found",
"instance": "urn:uuid:01234567-89ab-cdef-0123-456789abcdef"
}Content-Type: application/problem+json
§no_std + alloc limitations
ErrorTypeMode is available under the alloc feature (its fields use
String), but the global accessors error_type_mode and
set_error_type_mode require the std feature because they rely on
std::sync::RwLock and std::env::var.
In a no_std + alloc environment you can still construct an
ErrorTypeMode value and call ErrorTypeMode::render directly, but
the automatic environment-variable resolution is unavailable.
Structs§
- ApiError
- RFC 9457 Problem Details error response.
- ApiError
Builder - Typestate builder for
ApiError. - Problem
Json - RFC 7807 / 9457 Problem Details response body with optional extension members.
- Validation
Error - A single field-level validation error, used in
ApiError::errors.
Enums§
- Error
Code - Machine-readable error code included in every API error response.
- Error
Type Mode - How the RFC 9457
typefield is rendered forErrorCode.
Traits§
- Http
Error - Implement this trait on domain error types to get a blanket
Fromimplementation intoApiErrorfor free.
Functions§
- error_
type_ mode - Returns the active
ErrorTypeMode. - set_
error_ type_ mode - Override the error type mode programmatically (call once at application startup).
- urn_
namespace - Returns the active URN namespace (convenience wrapper around
error_type_mode). Only meaningful when inErrorTypeMode::Urnmode.