1 unstable release
new 0.1.0 | Dec 7, 2024 |
---|
#2 in #err
106 downloads per month
8KB
186 lines
Errors for conveniently attaching status codes to error cases.
use api_err::{CategoryExt, Context};
fn add_one(request: &str) -> api_err::Result<String> {
let input = request.parse::<i64>().bad_request()?;
let output = input.checked_add(1).context("Input too large").bad_request()?;
Ok(output.to_string())
}
Errors without a category attached default to the "Internal Server"-like error.
Dependencies
~135KB