#![allow(missing_docs)]
use thiserror::Error;
pub type AnalysisResult<T> = Result<T, AnalysisError>;
#[derive(Error, Debug)]
pub enum AnalysisError {
#[error("Solidity compilation failed: {0}")]
CompilationError(String),
#[error("AST parsing error: {0}")]
AstParsingError(String),
#[error("Bytecode analysis error: {0}")]
BytecodeAnalysisError(String),
#[error("Control flow graph construction error: {0}")]
CfgError(String),
#[error("Data flow analysis error: {0}")]
DataFlowError(String),
#[error("Symbolic execution error: {0}")]
SymbolicExecutionError(String),
#[error("Contract execution error: {0}")]
ExecutionError(String),
#[error("I/O error: {0}")]
IoError(#[from] std::io::Error),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("Internal error: {0}")]
Internal(String),
}
impl AnalysisError {
pub fn compilation(msg: impl Into<String>) -> Self {
AnalysisError::CompilationError(msg.into())
}
pub fn ast_parsing(msg: impl Into<String>) -> Self {
AnalysisError::AstParsingError(msg.into())
}
pub fn bytecode(msg: impl Into<String>) -> Self {
AnalysisError::BytecodeAnalysisError(msg.into())
}
pub fn cfg(msg: impl Into<String>) -> Self {
AnalysisError::CfgError(msg.into())
}
pub fn dataflow(msg: impl Into<String>) -> Self {
AnalysisError::DataFlowError(msg.into())
}
pub fn symbolic(msg: impl Into<String>) -> Self {
AnalysisError::SymbolicExecutionError(msg.into())
}
pub fn execution(msg: impl Into<String>) -> Self {
AnalysisError::ExecutionError(msg.into())
}
pub fn internal(msg: impl Into<String>) -> Self {
AnalysisError::Internal(msg.into())
}
}