[][src]Macro witcher::match_err

macro_rules! match_err {
    ($err:expr, { $($var:ident : $kind:ty => $arm:expr),*, _ => $default:expr }) => { ... };
}

Match on error types. This only works with errors implementing the std::error::Error trait as it makes use of the standard is and downcast_ref implementations.

Examples

use witcher::prelude::*;
let err = std::io::Error::new(std::io::ErrorKind::Other, "oh no!");
let res = match_err!(&err, {
    _x: std::io::Error => true,
    _ => false
});
assert!(res);