neo_solidity/frontend/
frontend_errors.rs

1/// Errors emitted by the frontend while parsing Solidity code.
2#[derive(Debug, Error)]
3pub enum FrontendError {
4    /// Parsing failed; the contained message aggregates all diagnostics.
5    #[error("Solidity parsing failed:\n{0}")]
6    Parse(String),
7
8    /// Invalid Solidity version pragma
9    #[error("Unsupported Solidity version: {0}")]
10    UnsupportedVersion(String),
11
12    /// Import resolution failed
13    #[error("Failed to resolve import '{path}': {reason}")]
14    ImportError { path: String, reason: String },
15
16    /// Contract not found in source
17    #[error("Contract '{0}' not found in source")]
18    ContractNotFound(String),
19}
20
21impl FrontendError {
22    /// Create a parse error with location info
23    pub fn parse_at(line: usize, column: usize, message: impl Into<String>) -> Self {
24        Self::Parse(format!("{}:{}: {}", line, column, message.into()))
25    }
26
27    /// Create an import error
28    pub fn import_error(path: impl Into<String>, reason: impl Into<String>) -> Self {
29        Self::ImportError {
30            path: path.into(),
31            reason: reason.into(),
32        }
33    }
34
35    /// Check if this is a recoverable error
36    pub fn is_recoverable(&self) -> bool {
37        matches!(self, Self::UnsupportedVersion(_))
38    }
39}
40