blob: 294159c9a8342724742646565234508360055d84 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
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)*)})}
}
#[derive(Debug)]
pub struct ParseError {
pub text: String
}
impl Error for ParseError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
None
}
}
impl Display for ParseError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Error: {}", self.text)
}
}
#[macro_export]
macro_rules! perr {
($($description:tt)*) => {crate::errors::ParseError{text: format!($($description)*)}}
}
pub type PResult<T> = std::result::Result<T, ParseError>;
|