Expand description
A generic Error container with HTTP 4xx or 5xx status code semantics and string context.
This crate tries to find the balance between too many error variants and zero context.
§Features
- http: when http is enabled,
ErrorStatuscan be converted toStatusCodeor(StatusCode, String)for easier integration with HTTP services.
§Examples
ⓘ
use std::io::{self, ErrorKind};
use anyhow::Result;
use error_status::ResultExt;
fn find_file() -> Result<(), io::Error> {
Err(ErrorKind::NotFound.into())
}
fn main() -> Result<()> {
find_file()
.not_found("Failed to read file")
.internal_error("Config file is not available")?;
Ok(())
}Structs§
- Error
Status - Error with context
Enums§
- Error
Kind - Error code modeled after HTTP StatusCode
Traits§
- Result
Ext - Methods to construct different
ErrorStatuss fromResult