2023-03-06 20:53:49 +04:00
|
|
|
use ctxerr_derive::ctxerr;
|
|
|
|
|
|
|
|
#[ctxerr]
|
|
|
|
pub enum ErrorKind {
|
2023-05-12 12:37:53 +04:00
|
|
|
#[error("Error: {0}")]
|
2023-03-06 20:53:49 +04:00
|
|
|
Error1(#[from] std::io::Error),
|
|
|
|
}
|
|
|
|
|
|
|
|
fn operation() -> Result<(), std::io::Error> {
|
|
|
|
std::fs::File::open("")?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test() -> Result<(), Error> {
|
2023-05-12 12:37:53 +04:00
|
|
|
Ok(operation().map_err(ErrorKind::from)?)
|
2023-03-06 20:53:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if let Err(err) = test() {
|
|
|
|
println!("{}", err);
|
2023-05-12 12:37:53 +04:00
|
|
|
|
|
|
|
println!("{:?}", err);
|
2023-03-06 20:53:49 +04:00
|
|
|
}
|
|
|
|
}
|