25 lines
410 B
Rust
25 lines
410 B
Rust
use ctxerr_derive::ctxerr;
|
|
|
|
#[ctxerr]
|
|
pub enum ErrorKind {
|
|
#[error("Error: {0}")]
|
|
Error1(#[from] std::io::Error),
|
|
}
|
|
|
|
fn operation() -> Result<(), std::io::Error> {
|
|
std::fs::File::open("")?;
|
|
Ok(())
|
|
}
|
|
|
|
fn test() -> Result<(), Error> {
|
|
Ok(operation().map_err(ErrorKind::from)?)
|
|
}
|
|
|
|
fn main() {
|
|
if let Err(err) = test() {
|
|
println!("{}", err);
|
|
|
|
println!("{:?}", err);
|
|
}
|
|
}
|