sentri_analyzer_evm/
errors.rs1#![allow(missing_docs)]
2use thiserror::Error;
5
6pub type AnalysisResult<T> = Result<T, AnalysisError>;
8
9#[derive(Error, Debug)]
11pub enum AnalysisError {
12 #[error("Solidity compilation failed: {0}")]
14 CompilationError(String),
15
16 #[error("AST parsing error: {0}")]
18 AstParsingError(String),
19
20 #[error("Bytecode analysis error: {0}")]
22 BytecodeAnalysisError(String),
23
24 #[error("Control flow graph construction error: {0}")]
26 CfgError(String),
27
28 #[error("Data flow analysis error: {0}")]
30 DataFlowError(String),
31
32 #[error("Symbolic execution error: {0}")]
34 SymbolicExecutionError(String),
35
36 #[error("Contract execution error: {0}")]
38 ExecutionError(String),
39
40 #[error("I/O error: {0}")]
42 IoError(#[from] std::io::Error),
43
44 #[error("JSON error: {0}")]
46 JsonError(#[from] serde_json::Error),
47
48 #[error("Internal error: {0}")]
50 Internal(String),
51}
52
53impl AnalysisError {
54 pub fn compilation(msg: impl Into<String>) -> Self {
56 AnalysisError::CompilationError(msg.into())
57 }
58
59 pub fn ast_parsing(msg: impl Into<String>) -> Self {
61 AnalysisError::AstParsingError(msg.into())
62 }
63
64 pub fn bytecode(msg: impl Into<String>) -> Self {
66 AnalysisError::BytecodeAnalysisError(msg.into())
67 }
68
69 pub fn cfg(msg: impl Into<String>) -> Self {
71 AnalysisError::CfgError(msg.into())
72 }
73
74 pub fn dataflow(msg: impl Into<String>) -> Self {
76 AnalysisError::DataFlowError(msg.into())
77 }
78
79 pub fn symbolic(msg: impl Into<String>) -> Self {
81 AnalysisError::SymbolicExecutionError(msg.into())
82 }
83
84 pub fn execution(msg: impl Into<String>) -> Self {
86 AnalysisError::ExecutionError(msg.into())
87 }
88
89 pub fn internal(msg: impl Into<String>) -> Self {
91 AnalysisError::Internal(msg.into())
92 }
93}