codegraph_parser_api/
errors.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4/// Errors that can occur during parsing
5#[derive(Error, Debug)]
6pub enum ParserError {
7    /// Failed to read file
8    #[error("IO error reading {0}: {1}")]
9    IoError(PathBuf, #[source] std::io::Error),
10
11    /// Syntax error in source code
12    #[error("Syntax error in {0}:{1}:{2}: {3}")]
13    SyntaxError(PathBuf, usize, usize, String),
14
15    /// File too large
16    #[error("File {0} exceeds maximum size ({1} bytes)")]
17    FileTooLarge(PathBuf, usize),
18
19    /// Parsing timeout
20    #[error("Parsing {0} exceeded timeout")]
21    Timeout(PathBuf),
22
23    /// Graph insertion error
24    #[error("Failed to insert into graph: {0}")]
25    GraphError(String),
26
27    /// Unsupported language feature
28    #[error("Unsupported language feature in {0}: {1}")]
29    UnsupportedFeature(PathBuf, String),
30
31    /// Generic parsing error
32    #[error("Parse error in {0}: {1}")]
33    ParseError(PathBuf, String),
34}
35
36/// Result type for parser operations
37pub type ParserResult<T> = Result<T, ParserError>;