rush_parser/
error.rs

1use crate::Span;
2
3pub type Result<'src, T> = std::result::Result<T, Box<Error<'src>>>;
4
5#[derive(Debug, PartialEq, Eq)]
6pub struct Error<'src> {
7    pub message: String,
8    pub span: Span<'src>,
9    pub source: &'src str,
10}
11
12impl<'src> Error<'src> {
13    pub fn new(message: String, span: Span<'src>, source: &'src str) -> Self {
14        Self {
15            message,
16            span,
17            source,
18        }
19    }
20
21    pub fn new_boxed(message: String, span: Span<'src>, source: &'src str) -> Box<Self> {
22        Self::new(message, span, source).into()
23    }
24}