Skip to main content

cljrs_types/
error.rs

1// Fields are read by the thiserror/miette derive macros; suppress false-positive
2// unused_assignments warnings until callers land in later phases.
3#![allow(unused)]
4
5/// The unified error/diagnostic type for all clojurust subsystems.
6#[derive(Debug, thiserror::Error, miette::Diagnostic)]
7pub enum CljxError {
8    #[error("read error: {message}")]
9    #[diagnostic(code(cljrs::read))]
10    ReadError {
11        message: String,
12        #[label("here")]
13        span: Option<miette::SourceSpan>,
14        #[source_code]
15        src: miette::NamedSource<String>,
16    },
17
18    #[error("eval error: {message}")]
19    #[diagnostic(code(cljrs::eval))]
20    EvalError {
21        message: String,
22        #[label("here")]
23        span: Option<miette::SourceSpan>,
24        #[source_code]
25        src: miette::NamedSource<String>,
26    },
27
28    #[error("I/O error: {0}")]
29    Io(#[from] std::io::Error),
30
31    #[error("Serialization error: {message}")]
32    SerializationError { message: String },
33}
34
35pub type CljxResult<T> = Result<T, CljxError>;