| Crates.io | snafu-tracing |
| lib.rs | snafu-tracing |
| version | 0.8.3 |
| created_at | 2025-04-21 13:04:45.851348+00 |
| updated_at | 2025-04-21 13:18:54.499908+00 |
| description | Snafu tracing is an error handling mechanism with pseudo-stack traces implemented through SNAFU, the proc macro trace_error, and the DebugTrace trait, inspired by GreptimeDB. |
| homepage | |
| repository | https://github.com/dancingpeanut/snafu-tracing |
| max_upload_size | |
| id | 1642652 |
| size | 6,803 |
Snafu tracing is an error handling mechanism with pseudo-stack traces implemented through SNAFU, the proc macro trace_error, and the DebugTrace trait, inspired by GreptimeDB.
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);
}
Or refer to: full example