indy_blssignatures/
error.rs

1use std::fmt::{self, Display, Formatter};
2
3#[derive(Clone, Debug, PartialEq, Eq)]
4/// The standard crate error type
5pub struct Error(&'static str);
6
7impl Error {
8    /// Create a new error instance
9    pub fn new(msg: &'static str) -> Self {
10        Self(msg)
11    }
12}
13
14impl Display for Error {
15    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
16        f.write_str(self.0)
17    }
18}
19
20/// Result type alias
21pub type Result<T> = ::core::result::Result<T, Error>;
22
23/// Shorthand for creating an error
24#[macro_export]
25macro_rules! err_msg {
26    ($msg:expr, $($args:tt)+) => {
27        $crate::error::Error::new($crate::error::ErrorKind::$type, format!($msg, $($args)+))
28    };
29    ($msg:expr) => {{
30        $crate::error::Error::new($msg)
31    }};
32}