forge-guard 0.3.6

Pre-deployment smart contract auditing framework for Foundry
Documentation
use thiserror::Error;

/// Unified error type for all forge-guard operations.
#[derive(Error, Debug)]
pub enum ForgeGuardError {
    // ── I/O & Filesystem ──────────────────────────────────────────
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("File not found: {0}")]
    FileNotFound(String),

    #[error("Invalid path: {0}")]
    InvalidPath(String),

    // ── Parsing ──────────────────────────────────────────────────
    #[error("Parse error: {0}")]
    Parse(String),

    #[error("TOML parse error: {0}")]
    Toml(#[from] toml::de::Error),

    #[error("JSON parse error: {0}")]
    Json(#[from] serde_json::Error),

    #[error("Regex error: {0}")]
    Regex(#[from] regex::Error),

    // ── Security ─────────────────────────────────────────────────
    #[error("Security check failed: {0}")]
    SecurityCheck(String),

    #[error("Critical vulnerability found: {0}")]
    CriticalVulnerability(String),

    #[error("Deployment blocked: {0}")]
    DeploymentBlocked(String),

    // ── Analysis ─────────────────────────────────────────────────
    #[error("Analysis error: {0}")]
    Analysis(String),

    #[error("AST parsing error: {0}")]
    AstParse(String),

    #[error("Bytecode analysis error: {0}")]
    BytecodeAnalysis(String),

    // ── Chain ────────────────────────────────────────────────────
    #[error("Unsupported chain: {0}")]
    UnsupportedChain(String),

    #[error("RPC error: {0}")]
    Rpc(String),

    // ── Plugin ───────────────────────────────────────────────────
    #[error("Plugin error: {0}")]
    Plugin(String),

    #[error("Plugin not found: {0}")]
    PluginNotFound(String),

    #[error("Plugin load error: {0}")]
    PluginLoad(String),

    // ── Configuration ────────────────────────────────────────────
    #[error("Configuration error: {0}")]
    Config(String),

    #[error("Environment error: {0}")]
    Env(String),

    // ── Cache ────────────────────────────────────────────────────
    #[error("Cache error: {0}")]
    Cache(String),

    // ── History ──────────────────────────────────────────────────
    #[error("SQLite error: {0}")]
    Sqlite(#[from] rusqlite::Error),

    // ── Execution ────────────────────────────────────────────────
    #[error("Command execution error: {0}")]
    Command(String),

    #[error("Subprocess error: {0}")]
    Subprocess(String),

    #[error("Timeout: {0}")]
    Timeout(String),

    // ── Internal ─────────────────────────────────────────────────
    #[error("Internal error: {0}")]
    Internal(String),

    #[error("Not implemented: {0}")]
    NotImplemented(String),

    #[error("{0}")]
    Anyhow(#[from] anyhow::Error),
}

/// Convenience alias.
pub type Result<T> = std::result::Result<T, ForgeGuardError>;