neo_devpack_solidity/frontend/
frontend_errors.rs1#[derive(Debug, Clone)]
5pub struct ParseDiagnostic {
6 pub message: String,
8 pub start: usize,
10 pub end: usize,
12}
13
14#[derive(Debug, Error)]
16pub enum FrontendError {
17 #[error("Solidity parsing failed:\n{0}")]
19 Parse(String),
20
21 #[error("Solidity parsing failed with {} error(s)", .0.len())]
24 ParseDiagnostics(Vec<ParseDiagnostic>),
25
26 #[error("Unsupported Solidity version: {0}")]
28 UnsupportedVersion(String),
29
30 #[error("Failed to resolve import '{path}': {reason}")]
32 ImportError { path: String, reason: String },
33
34 #[error("Contract '{0}' not found in source")]
36 ContractNotFound(String),
37}
38
39impl FrontendError {
40 pub fn parse_at(line: usize, column: usize, message: impl Into<String>) -> Self {
42 Self::Parse(format!("{}:{}: {}", line, column, message.into()))
43 }
44
45 pub fn import_error(path: impl Into<String>, reason: impl Into<String>) -> Self {
47 Self::ImportError {
48 path: path.into(),
49 reason: reason.into(),
50 }
51 }
52
53 pub fn is_recoverable(&self) -> bool {
55 matches!(self, Self::UnsupportedVersion(_))
56 }
57}
58