Misusing v2 `Try` and `?` to make unit tests nicer

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.

6 Likes