monolake_core/error.rs
1/// A type alias for `anyhow::Error`, representing any error type.
2///
3/// This type is used throughout the crate to represent errors that can be of any type,
4/// leveraging the flexibility of the `anyhow` crate for error handling.
5pub type AnyError = anyhow::Error;
6
7/// A type alias for `Result<T, E>` where `E` defaults to [`AnyError`](AnyError).
8///
9/// This type provides a convenient way to return results that can contain any error type,
10/// defaulting to [`AnyError`] if no specific error type is specified.
11///
12/// # Type Parameters
13///
14/// * `T` - The type of the successful result.
15/// * `E` - The error type, defaulting to [`AnyError`].
16pub type AnyResult<T, E = AnyError> = std::result::Result<T, E>;
17#[macro_export]
18macro_rules! bail_into {
19 ($msg:literal $(,)?) => {
20 return Err(::anyhow::anyhow!($msg).into())
21 };
22 ($err:expr $(,)?) => {
23 return Err(::anyhow::anyhow!($err).into())
24 };
25 ($fmt:expr, $($arg:tt)*) => {
26 return Err(::anyhow::anyhow!($fmt, $($arg)*).into())
27 };
28}