error macro suite
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
c111d2e395
commit
93ec4e579b
1 changed files with 42 additions and 0 deletions
|
@ -15,6 +15,48 @@ use ruma::{
|
||||||
|
|
||||||
use crate::{debug::panic_str, debug_error, error};
|
use crate::{debug::panic_str, debug_error, error};
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! err {
|
||||||
|
(error!($($args:tt),+)) => {{
|
||||||
|
error!($($args),+);
|
||||||
|
$crate::error::Error::Err(format!($($args),+))
|
||||||
|
}};
|
||||||
|
|
||||||
|
(debug_error!($($args:tt),+)) => {{
|
||||||
|
debug_error!($($args),+);
|
||||||
|
$crate::error::Error::Err(format!($($args),+))
|
||||||
|
}};
|
||||||
|
|
||||||
|
($variant:ident(error!($($args:tt),+))) => {{
|
||||||
|
error!($($args),+);
|
||||||
|
$crate::error::Error::$variant(format!($($args),+))
|
||||||
|
}};
|
||||||
|
|
||||||
|
($variant:ident(debug_error!($($args:tt),+))) => {{
|
||||||
|
debug_error!($($args),+);
|
||||||
|
$crate::error::Error::$variant(format!($($args),+))
|
||||||
|
}};
|
||||||
|
|
||||||
|
($variant:ident(format!($($args:tt),+))) => {
|
||||||
|
$crate::error::Error::$variant(format!($($args),+))
|
||||||
|
};
|
||||||
|
|
||||||
|
($variant:ident($($args:tt),+)) => {
|
||||||
|
$crate::error::Error::$variant(format!($($args),+))
|
||||||
|
};
|
||||||
|
|
||||||
|
($string:literal$(,)? $($args:tt),*) => {
|
||||||
|
$crate::error::Error::Err(format!($string, $($args),*))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! Err {
|
||||||
|
($($args:tt)*) => {
|
||||||
|
Err($crate::err!($($args)*))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error)]
|
#[derive(thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("PANIC!")]
|
#[error("PANIC!")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue