1 unstable release
Uses new Rust 2024
| 0.1.0 | Jul 5, 2025 |
|---|
#1609 in HTTP server
74 downloads per month
Used in axum-error-handler
12KB
100 lines
Error Response Context
This module provides types and traits for creating standardized error response contexts that can be used with custom error response functions in the Axum Error Handler crate.
The main purpose is to allow custom error response functions to receive structured error information (status code, error code, message) that can be used to generate custom response formats while maintaining consistency with the error handling system.
Example Usage
use axum_error_handler::ErrorResponseContext;
use axum::response::Response;
fn custom_error_handler(ctx: ErrorResponseContext) -> Response {
// Access error information
let status = ctx.status_code().unwrap_or(500);
let code = ctx.code().unwrap_or(&"UNKNOWN".to_string());
let message = ctx.message().unwrap_or(&"Error occurred".to_string());
// Create custom response format
Response::builder()
.status(status)
.body(format!("Error {}: {}", code, message).into())
.unwrap()
}
Dependencies
~4.5–8.5MB
~150K SLoC