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
use crate::parser::span::Span;
#[derive(Debug, Clone)]
pub struct SyntaxError {
pub message: String,
pub span: Span,
}
impl std::fmt::Display for SyntaxError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.message)
}
}
impl std::error::Error for SyntaxError {}
pub trait ErrorWithSpan {
fn get_message(&self) -> Span;
fn get_span(&self) -> Span;
}
impl SyntaxError {
pub fn new<T: ToString>(message: T, span: Span) -> Self {
Self {
message: message.to_string(),
span,
}
}
}