[−][src]Macro dynerr::dynmatch
Performs a dynamic match operation on multiple error types.
types must be specified beforehand with the "type" keyword.
match arms (excluding the final exhaustive arm) must be specified with the "arm" keyword.
Example
let _i = match example(20) { Ok(i) => i, Err(e) => { dynmatch!(e, //the DynError to be matched type ExampleError1 { //an error type arm ExampleError1::ThisError(2) => logged_panic!("it was 2!"), //arm [pattern] => {code} _ => panic!("{}",e) //_ => {code} }, type ExampleError2 { arm ExampleError2::ThatError(8) => logged_panic!("it was 8!", "test.log"), arm ExampleError2::ThatError(9) => 9, _ => panic!("{}",e) }, type std::io::Error { //an error type not defined by you arm i if i.kind() == std::io::ErrorKind::NotFound => 5, //a match guard included in the match _ => panic!("{}", e) }, _ => panic!("{}",e) //what to do if error type isn't found ) } };