use std::path::PathBuf;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, RaxitError>;
#[derive(Error, Debug)]
pub enum RaxitError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Configuration error: {0}")]
Config(String),
#[error("Parse error in {file}: {message}")]
Parse { file: PathBuf, message: String },
#[error("Framework not supported: {0}")]
UnsupportedFramework(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Analysis error: {0}")]
Analysis(String),
#[error("Invalid path: {0}")]
InvalidPath(PathBuf),
#[error("Schema validation error: {0}")]
SchemaValidation(String),
}
impl From<serde_json::Error> for RaxitError {
fn from(err: serde_json::Error) -> Self {
RaxitError::Serialization(err.to_string())
}
}
impl From<serde_yaml::Error> for RaxitError {
fn from(err: serde_yaml::Error) -> Self {
RaxitError::Serialization(err.to_string())
}
}
impl From<walkdir::Error> for RaxitError {
fn from(err: walkdir::Error) -> Self {
RaxitError::Io(std::io::Error::other(err.to_string()))
}
}