Files
simple-rust-tests/__err/thiserror_anyhow/src/main.rs

20 lines
395 B
Rust

use thiserror::Error;
use anyhow::{Context, Result};
#[derive(Error, Debug)]
pub enum SimpleError {
#[error("error status")]
ErrorStatus(u32),
#[error("unknown error")]
Unknown,
}
fn main() {
do_something().unwrap();
}
fn do_something() -> Result<String, Box<dyn std::error::Error>> {
Err(Box::new(SimpleError::Unknown)).with_context(|| format!("Error unknown!"))?
}