cas_error/
lib.rs

1//! Contains the common [`ErrorKind`] trait used by all parsing and evaluation errors to display
2//! user-facing error messages.
3
4use ariadne::{Color, Report};
5use std::{fmt::Debug, ops::Range};
6
7/// The color to use to highlight expressions.
8pub const EXPR: Color = Color::RGB(52, 235, 152);
9
10/// Represents any kind of error that can occur during some operation.
11pub trait ErrorKind: Debug + Send {
12    /// Builds the report for this error.
13    fn build_report(
14        &self,
15        src_id: &'static str,
16        spans: &[Range<usize>],
17    ) -> Report<(&'static str, Range<usize>)>;
18}