Skip to main content

Crate snafu_tracing

Crate snafu_tracing 

Source
Expand description

Snafu tracing

§Example

use snafu::Snafu;
use snafu_tracing::{DebugTrace, trace_error, quick_tracing};
 
pub type Result<T, E = Error> = std::result::Result<T, E>;
 
#[trace_error]
#[derive(Snafu, DebugTrace)]
#[snafu(module, context(suffix(false)), visibility(pub))]
pub enum Error {
    #[snafu(display("{_error}"))]
    Any { _error: String },
    #[snafu(display("{error_source}"))]
    Wrap {
        #[snafu(source(from(Box<dyn std::error::Error + Send + Sync>, |e| e)))]
        error_source: Box<dyn std::error::Error + Send + Sync>,
    },
}
 
quick_tracing!(anyerr, crate::error::Any);
 
pub fn hello_err() -> Result<()> {
    let _e = anyerr!("Any error test! {}", 123);
    Err(anyerr!("Any error test!"))
}
 
fn main() {
    let e = hello_err();
    println!("{:?}", e);
}

Macros§

quick_tracing

Traits§

DebugTrace

Attribute Macros§

trace_error

Derive Macros§

DebugTrace