Wouldn't using anyhow::Error
as error type work? It should capture backtraces at creation time. Also I think you can have something like:
enum PanicError {}
impl<T: Error> From<T> for PanicError {
fn from(e: T) {
panic!("test failed with: {e}");
}
}
and then use Result<(), PanicError>
as return type.