-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to get the deepest
Whatever
error backtrace
- Loading branch information
1 parent
76e93f9
commit a7dccef
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
compatibility-tests/backtrace-shim/tests/whatever_nested.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use snafu::{whatever, ResultExt, Whatever}; | ||
|
||
fn inner_outer() -> Result<(), Whatever> { | ||
not_a_whatever().with_whatever_context(|_| format!("Outer failure")) | ||
} | ||
|
||
fn not_a_whatever() -> Result<(), Box<dyn std::error::Error>> { | ||
inner_whatever().map_err(Into::into) | ||
} | ||
|
||
fn inner_whatever() -> Result<(), Whatever> { | ||
whatever!("Inner failure"); | ||
} | ||
|
||
#[test] | ||
fn backtrace_method_delegates_to_nested_whatever() { | ||
let e = inner_outer().unwrap_err(); | ||
let bt = e.backtrace().expect("Must have a backtrace"); | ||
assert!(bt.to_string().contains("::inner_whatever::")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters