Skip to main content

ai_agent_bitcoin_escrow/
error.rs

1//! Error types for the AI Agent Bitcoin Escrow Library.
2
3use thiserror::Error;
4
5/// Main error type for the escrow library.
6#[derive(Error, Debug)]
7pub enum EscrowError {
8    /// Error related to Bitcoin operations.
9    #[error("Bitcoin error: {0}")]
10    Bitcoin(#[from] bitcoin::consensus::encode::Error),
11
12    /// Error related to key operations.
13    #[error("Key error: {0}")]
14    Key(String),
15
16    /// Error related to multisig operations.
17    #[error("Multisig error: {0}")]
18    Multisig(String),
19
20    /// Error related to escrow contract operations.
21    #[error("Escrow contract error: {0}")]
22    Contract(String),
23
24    /// Error related to condition evaluation.
25    #[error("Condition error: {0}")]
26    Condition(String),
27
28    /// Error related to oracle operations.
29    #[error("Oracle error: {0}")]
30    Oracle(String),
31
32    /// Error related to audit logging.
33    #[error("Audit error: {0}")]
34    Audit(String),
35
36    /// Error related to transaction operations.
37    #[error("Transaction error: {0}")]
38    Transaction(String),
39
40    /// Error related to signing operations.
41    #[error("Signing error: {0}")]
42    Signing(String),
43
44    /// Error related to descriptor operations.
45    #[error("Descriptor error: {0}")]
46    Descriptor(String),
47
48    /// Invalid state for the requested operation.
49    #[error("Invalid state: {0}")]
50    InvalidState(String),
51
52    /// Missing required data.
53    #[error("Missing data: {0}")]
54    MissingData(String),
55
56    /// Serialization/deserialization error.
57    #[error("Serialization error: {0}")]
58    Serialization(#[from] serde_json::Error),
59
60    /// IO error.
61    #[error("IO error: {0}")]
62    Io(#[from] std::io::Error),
63
64    /// BDK wallet error.
65    #[error("Wallet error: {0}")]
66    Wallet(String),
67
68    /// Generic error with message.
69    #[error("{0}")]
70    Other(String),
71}
72
73/// Result type alias for escrow operations.
74pub type Result<T> = std::result::Result<T, EscrowError>;