Expand description
Error type returned from user-defined route handlers.
The server converts a HandlerError into an ICAP response — by default
500 Internal Server Error — and logs the underlying source at WARN
level. The connection stays open and is ready to serve the next request.
HandlerError is intentionally not a std::error::Error: that lets it
accept any std::error::Error + Send + Sync + 'static through a blanket
From impl, so handlers can use ? to propagate crate::Error,
std::io::Error, or any user-defined error without manual mapping.
§Example
use icap_rs::{HandlerError, HandlerResult, IncomingRequest, Response, StatusCode};
async fn handler(_req: IncomingRequest) -> HandlerResult<Response> {
// Propagate a typed error from any layer — turns into 500 automatically.
let resp = Response::no_content_with_istag("svc-1.0")?;
Ok(resp)
}
async fn handler_bad_request(_req: IncomingRequest) -> HandlerResult<Response> {
Err(HandlerError::new(StatusCode::BAD_REQUEST).with_message("missing URL"))
}Structs§
- Handler
Error - Error returned from a route handler.
Type Aliases§
- BoxError
- Boxed
std::error::Errorcarried as the source of aHandlerError. - Handler
Result - Convenient alias for results returned from route handlers.