pub struct HttpErrorMapping {
pub codes: BTreeMap<String, u16>,
pub kinds: BTreeMap<String, u16>,
}Expand description
Route-level business error to HTTP status mapping.
codes maps an exact business error code to a status; kinds maps an
exact business error kind to a status. Both tables are case-sensitive and
may be empty.
The mapping is a separate route-level field and never lives on
crate::error_handler::ErrorHandlerConfig. It carries no message or
data: the reply body for a business error is exactly
{"error": <code>, "kind": <kind>}, because runtime exchange data is
untrusted and no mapping authorizes its disclosure.
Fields§
§codes: BTreeMap<String, u16>Exact business error code to HTTP status.
kinds: BTreeMap<String, u16>Exact business error kind to HTTP status.
Implementations§
Source§impl HttpErrorMapping
impl HttpErrorMapping
Sourcepub fn with_code(self, code: impl Into<String>, status: u16) -> Self
pub fn with_code(self, code: impl Into<String>, status: u16) -> Self
Add a code entry, returning self for builder-style construction.
Sourcepub fn with_kind(self, kind: impl Into<String>, status: u16) -> Self
pub fn with_kind(self, kind: impl Into<String>, status: u16) -> Self
Add a kind entry, returning self for builder-style construction.
Sourcepub fn validate(&self) -> Result<(), HttpErrorMappingError>
pub fn validate(&self) -> Result<(), HttpErrorMappingError>
Validate every entry: non-blank keys and statuses in 400..=599.
§Errors
Returns the first HttpErrorMappingError found, checking the
codes table before the kinds table.