Skip to main content

raxit_core/
error.rs

1//! Error types for RAXIT Core
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6pub type Result<T> = std::result::Result<T, RaxitError>;
7
8#[derive(Error, Debug)]
9pub enum RaxitError {
10    #[error("I/O error: {0}")]
11    Io(#[from] std::io::Error),
12
13    #[error("Configuration error: {0}")]
14    Config(String),
15
16    #[error("Parse error in {file}: {message}")]
17    Parse { file: PathBuf, message: String },
18
19    #[error("Framework not supported: {0}")]
20    UnsupportedFramework(String),
21
22    #[error("Serialization error: {0}")]
23    Serialization(String),
24
25    #[error("Analysis error: {0}")]
26    Analysis(String),
27
28    #[error("Invalid path: {0}")]
29    InvalidPath(PathBuf),
30
31    #[error("Schema validation error: {0}")]
32    SchemaValidation(String),
33}
34
35impl From<serde_json::Error> for RaxitError {
36    fn from(err: serde_json::Error) -> Self {
37        RaxitError::Serialization(err.to_string())
38    }
39}
40
41impl From<serde_yaml::Error> for RaxitError {
42    fn from(err: serde_yaml::Error) -> Self {
43        RaxitError::Serialization(err.to_string())
44    }
45}
46
47impl From<walkdir::Error> for RaxitError {
48    fn from(err: walkdir::Error) -> Self {
49        RaxitError::Io(std::io::Error::other(err.to_string()))
50    }
51}