Skip to main content

ryo_source/
error.rs

1//! Error types for Rust AST manipulation.
2
3use thiserror::Error;
4
5/// Result type for source operations.
6pub type SourceResult<T> = Result<T, SourceError>;
7
8/// Errors that can occur during AST manipulation.
9#[derive(Debug, Error)]
10pub enum SourceError {
11    /// Failed to parse Rust source code.
12    #[error("Parse error: {0}")]
13    ParseError(String),
14
15    /// File I/O error.
16    #[error("IO error: {0}")]
17    IoError(#[from] std::io::Error),
18
19    /// Invalid transformation.
20    #[error("Invalid transformation: {0}")]
21    InvalidTransformation(String),
22}
23
24impl From<syn::Error> for SourceError {
25    fn from(err: syn::Error) -> Self {
26        SourceError::ParseError(err.to_string())
27    }
28}