Crate error_status

Crate error_status 

Source
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, ErrorStatus can be converted to StatusCode or (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§

ErrorStatus
Error with context

Enums§

ErrorKind
Error code modeled after HTTP StatusCode

Traits§

ResultExt
Methods to construct different ErrorStatuss from Result