diff --git a/lib/core/libimagerror/src/trace.rs b/lib/core/libimagerror/src/trace.rs index 3fbc4faf..526654d5 100644 --- a/lib/core/libimagerror/src/trace.rs +++ b/lib/core/libimagerror/src/trace.rs @@ -114,13 +114,17 @@ fn print_trace_dbg(idx: u64, e: &Error) { /// /// and variants pub trait MapErrTrace { + type Output; + fn map_err_trace(self) -> Self; fn map_err_dbg_trace(self) -> Self; fn map_err_trace_exit(self, code: i32) -> Self; + fn map_err_trace_exit_unwrap(self, code: i32) -> Self::Output; fn map_err_trace_maxdepth(self, max: u64) -> Self; } impl MapErrTrace for Result { + type Output = U; /// Simply call `trace_error()` on the Err (if there is one) and return the error. /// @@ -143,6 +147,11 @@ impl MapErrTrace for Result { self.map_err(|e| { trace_error_exit(&e, code) }) } + /// Helper for calling map_err_trace_exit(n).unwrap() in one call + fn map_err_trace_exit_unwrap(self, code: i32) -> Self::Output { + self.map_err_trace_exit(code).unwrap() + } + /// Simply call `trace_error_maxdepth(max)` on the Err (if there is one) and return the error. /// /// This does nothing besides the side effect of printing the error trace to a certain depth