Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors

aztec-rs has a single top-level error type, re-exported from aztec_core::error::Error. Every crate in the workspace converts its internal failures into this type.

The Error Enum

pub enum Error {
    Transport(String),           // HTTP / network failure
    Json(String),                // Serde JSON failure
    Abi(String),                 // ABI or artifact validation failure
    InvalidData(String),         // Invalid or unexpected data
    Rpc { code: i64, message: String }, // JSON-RPC server error
    Reverted(String),            // Tx execution reverted
    Timeout(String),             // Operation timed out
}

Conversions

Built-in From impls collapse common lower-level errors into Error:

  • reqwest::ErrorError::Transport
  • serde_json::ErrorError::Json
  • url::ParseErrorError::Transport

Most crate-local errors also implement From<_> for Error; application code typically only sees aztec_rs::Error.

Variant Reference

VariantTypical source
Transportaztec-rpc, aztec-node-client, aztec-ethereum
JsonAny layer decoding RPC responses or artifacts
Abiaztec-core::abi, aztec-contract
InvalidDataField parsing, address parsing, hex decoding
RpcNode returns a non-success JSON-RPC envelope
RevertedSimulation or inclusion revert from a public call
TimeoutReadiness pollers (wait_for_node, wait_for_tx, …)

Pattern Matching

match result {
    Err(aztec_rs::Error::Reverted(msg)) => eprintln!("tx reverted: {msg}"),
    Err(aztec_rs::Error::Rpc { code, message }) => eprintln!("rpc {code}: {message}"),
    Err(e) => eprintln!("other error: {e}"),
    Ok(v) => v,
}

Rustdoc

cargo doc --open

Search for Error in the generated docs to see conversion impls per crate.