Add decode_err! to help with formatted decode error generation

This commit is contained in:
Ryan Leckey 2020-03-20 19:55:00 -07:00
parent 24d62dd464
commit 9973fa6357

View File

@ -236,6 +236,17 @@ macro_rules! impl_fmt_error {
};
}
#[allow(unused_macros)]
macro_rules! decode_err {
($s:literal, $($args:tt)*) => {
crate::Error::Decode(format!($s, $($args)*).into())
};
($expr:expr) => {
crate::Error::decode($expr)
};
}
/// An unexpected `NULL` was encountered during decoding.
///
/// Returned from `Row::get` if the value from the database is `NULL`