#[macro_export]
macro_rules! bail_attach {
($err:expr $(, $($attachment:expr),+)? $(,)?) => {
return Err($crate::report_attach!($err $(, $($attachment),+)?))?
};
}
#[macro_export]
macro_rules! ensure_attach {
($cond:expr, $err:expr $(, $($attachment:expr),+)? $(,)?) => {{
let cond: bool = $cond;
if !cond {
$crate::bail_attach!($err, concat!("condition failed: ", stringify!($cond)) $(, $($attachment),+)?);
}
}};
}
#[macro_export]
macro_rules! ensure_matches_attach {
($expr:expr, $pat:pat, $err:expr $(, $($attachment:expr),+)? $(,)?) => {
let $pat = $expr else {
$crate::bail_attach!($err, concat!("condition failed: let ", stringify!($pat), " = ", stringify!($expr))
$(, $($attachment),+)?);
};
};
}
#[macro_export]
macro_rules! report_attach {
($err:expr $(, $($attachment:expr),+)? $(,)?) => {
$crate::error::Report::from($err)
$($(.attach_printable($attachment))+)?
};
}