protospec_build/
result.rs

1use std::fmt;
2pub use std::io::ErrorKind;
3
4pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
5
6pub type Result<T> = std::result::Result<T, Error>;
7pub type StdResult<T, E> = std::result::Result<T, E>;
8
9#[derive(Debug)]
10pub struct ProtoSpecError {
11    message: String,
12}
13
14impl ProtoSpecError {
15    pub fn new(message: String) -> ProtoSpecError {
16        ProtoSpecError { message }
17    }
18}
19
20impl fmt::Display for ProtoSpecError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        write!(f, "ProtoSpecError {{ {} }}", self.message)
23    }
24}
25
26impl std::error::Error for ProtoSpecError {}
27
28#[macro_export]
29macro_rules! protospec_err {
30    ($($arg:tt)*) => { Box::new(ProtoSpecError::new(format!($($arg)*))) }
31}