cdumay_error_http
This crate provides structured mapping from HTTP status codes to custom application error types using the cdumay_core crate. It is especially useful when you want to handle HTTP error responses in a standardized and extensible way.
Features
- Maps common HTTP status codes (300–511) to well-defined application-specific errors.
- Integrates seamlessly with the
cdumay_coreecosystem. - Allows contextual error data and custom messages.
- Supports conversion from
u16
Usage
Define Error Kinds and Errors
The define_kinds! macro associates each HTTP status code with:
- A numerical HTTP status code
- A descriptive error label
The define_errors! macro maps those kinds into named error types (e.g., NotFound, TooManyRequests, etc.).
use BTreeMap;
use Value;
use HTTPErrorConverter;
let mut context = new;
context.insert;
let error = from_u16;
println!;