//! Crate-wide error type. use thiserror::Error; /// Anything that can go wrong inside `aldabra-dao`. /// /// Boundary rule: `DaoError` does NOT wrap `aldabra_core::WalletError` or /// `aldabra_chain::ChainError` directly — those sit at different layers. /// Convert to a [`DaoError::Backend`] string via the `?`-helper at call sites /// to keep the public error surface flat for MCP consumers. #[derive(Debug, Error)] pub enum DaoError { /// Per-DAO config file is missing, malformed, or names a DAO we don't have. #[error("dao config: {0}")] Config(String), /// Bech32 / address parse failure. #[error("address: {0}")] Address(String), /// PlutusData encode/decode failure — the on-chain datum didn't match /// the shape we expected. #[error("datum: {0}")] Datum(String), /// CBOR encode/decode failure (lower-level than [`Self::Datum`]). #[error("cbor: {0}")] Cbor(String), /// Backend (Koios / submit) returned an error. #[error("backend: {0}")] Backend(String), /// We couldn't find a required reference-script UTxO on chain. #[error("reference script not found: {0}")] RefScript(String), /// Caller asked for something the DAO can't provide right now (no active /// proposal, no stake registered, locked stake, etc). #[error("invalid state: {0}")] State(String), /// I/O error against the DAO config dir or similar. #[error("io: {0}")] Io(#[from] std::io::Error), /// JSON serialization failure for [`crate::config::DaoConfig`]. #[error("json: {0}")] Json(#[from] serde_json::Error), } pub type DaoResult = Result;