rama_error/
macros.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/// A macro to create a new error from a string literal,
/// formatted string, or an existing error.
///
/// See the [module level documentation](crate::error) for more information.
///
/// ## Examples
///
/// ```
/// use rama_error::error;
///
/// let err = error!("An error occurred");
/// let err = error!("An error occurred: {}", 42);
/// let err = error!(std::io::Error::new(std::io::ErrorKind::Other, "oh no!"));
/// ```
#[doc(hidden)]
#[macro_export]
macro_rules! __error {
    ($msg:literal $(,)?) => ({
        $crate::OpaqueError::from_display($msg)
    });
    ($fmt:literal, $($arg:tt),+ $(,)?) => ({
        $crate::OpaqueError::from_display(format!($fmt, $($arg)*))
    });
    ($err:expr $(,)?) => ({
        $crate::OpaqueError::from_std($err)
    });
}
pub use crate::__error as error;