macro_rules! try_validation {
($e:expr, $where:expr,
$( $( $p:pat_param )|+ => $msg:expr ),+ $(,)?
) => { ... };
}Expand description
If $e throws an error matching the pattern, throw a validation failure.
Other errors are passed back to the caller, unchanged – and if they reach the root of
the visitor, we make sure only validation errors and InvalidProgram errors are left.
This lets you use the patterns as a kind of validation list, asserting which errors
can possibly happen:
ⓘ
let v = try_validation!(some_fn(x), some_path, {
Foo | Bar | Baz => format!("some failure involving {x}"),
});The patterns must be of type UndefinedBehaviorInfo.