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