summaryrefslogtreecommitdiff
path: root/src/errors.rs
blob: c58f2ff65f42a259172ff3f41fdd976386f7cff7 (plain)
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

use std::error::Error;
use std::fmt::{Display, Formatter};

pub type AnyError = Box<dyn Error + 'static>;
pub type Result<T> = std::result::Result<T, AnyError>;

#[derive(Debug)]
pub struct AError {
	pub text: String
}
impl Error for AError {
	fn source(&self) -> Option<&(dyn Error + 'static)> {
		None
	}
}
impl Display for AError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "Error: {}", self.text)
    }
}
#[macro_export]
macro_rules! aerr {
	($($description:tt)*) => {Box::new(crate::errors::AError{text: format!($($description)*)})}
}