Macro pliron::verify_error
source ยท macro_rules! verify_error { ($loc: expr, $($t:tt)*) => { ... }; }
Expand description
To create Result, use verify_err! instead. The macro also accepts format! like arguments to create one-off errors.
use thiserror::Error;
use pliron::{verify_error, result::{Result, ErrorKind, Error}, location::Location};
#[derive(Error, Debug)]
#[error("sample error")]
pub struct SampleErr;
assert!(
matches!(
verify_error!(Location::Unknown, SampleErr),
Error {
kind: ErrorKind::VerificationFailed,
err,
loc: _,
} if err.is::<SampleErr>()
));
let res_msg: Error = verify_error!(Location::Unknown, "Some formatted {}", 0);
assert_eq!(
res_msg.err.to_string(),
"Some formatted 0"
);