debug-try
This crate contains an attribute macro that can help you debug errors in your program.
In a function marked with the #[debug_try]
attribute, any errors propagated with the ?
operator inside that function will be logged, printing the file, line and column to standard output.
If nested = true
is set in the attribute, then the same will apply to functions and closures defined inside the marked function as well.
Note. This crate requires the proc_macro_diagnostic
and proc_macro_span
features, so only Rust nightly is supported.
Example
// my_func.rs
use ;
use debug_try;
When invoked, the following will be printed to standard output:
Error propagated (my_func.rs:8:33): No such file or directory (os error 2)
Error propagated (my_func.rs:12:65): No such file or directory (os error 2)