macro_rules! arg_err {
($loc: expr, $($t:tt)*) => { ... };
}Expand description
Create ErrorKind::InvalidArgument Result from any core::error::Error object. To create Error, use arg_error! instead. The macro also accepts format! like arguments to create one-off errors.
use thiserror::Error;
use pliron::{arg_err, result::{Result, ErrorKind, Error}, location::Location};
#[derive(Error, Debug)]
#[error("sample error")]
pub struct SampleErr;
assert!(
matches!(
arg_err!(Location::Unknown, SampleErr),
Result::<()>::Err(Error {
kind: ErrorKind::InvalidArgument,
err,
..
}) if err.is::<SampleErr>()
));
let res_msg: Result<()> = arg_err!(Location::Unknown, "Some formatted {}", 0);
assert_eq!(
res_msg.unwrap_err().err.to_string(),
"Some formatted 0"
);