cas_parser/parser/error/
mod.rs1pub mod kind;
2
3use ariadne::Report;
4use cas_error::ErrorKind;
5use std::ops::Range;
6
7#[derive(Debug)]
9pub struct Error {
10 pub spans: Vec<Range<usize>>,
12
13 pub kind: Box<dyn ErrorKind>,
15}
16
17impl Error {
18 pub fn new(spans: Vec<Range<usize>>, kind: impl ErrorKind + 'static) -> Self {
20 Self { spans, kind: Box::new(kind) }
21 }
22
23 pub fn build_report(&self) -> Report<(&'static str, Range<usize>)> {
25 self.kind.build_report("input", &self.spans)
26 }
27}