tap_agent/
error.rs

1//! Error handling for TAP Agent
2//!
3//! This module provides error types and utilities for the TAP Agent.
4
5use thiserror::Error;
6
7/// Type alias for Results with TAP Agent errors
8pub type Result<T> = std::result::Result<T, Error>;
9
10/// Error types for TAP Agent
11#[derive(Error, Debug)]
12pub enum Error {
13    /// Core TAP errors
14    #[error("Core error: {0}")]
15    Core(#[from] tap_msg::error::Error),
16
17    /// Validation errors
18    #[error("Validation error: {0}")]
19    Validation(String),
20
21    /// DID resolution errors
22    #[error("DID resolution error: {0}")]
23    DidResolution(String),
24
25    /// Error related to invalid DID
26    #[error("Invalid DID")]
27    InvalidDID,
28
29    /// Error for unsupported DID method
30    #[error("Unsupported DID method: {0}")]
31    UnsupportedDIDMethod(String),
32
33    /// Error when failed to acquire resolver read lock
34    #[error("Failed to acquire resolver read lock")]
35    FailedToAcquireResolverReadLock,
36
37    /// Error when failed to acquire resolver write lock
38    #[error("Failed to acquire resolver write lock")]
39    FailedToAcquireResolverWriteLock,
40
41    /// Error related to missing configuration
42    #[error("Missing configuration: {0}")]
43    MissingConfig(String),
44
45    /// Error related to cryptographic operations
46    #[error("Crypto error: {0}")]
47    Crypto(String),
48
49    /// Error related to cryptographic operations during signing/encryption
50    #[error("Cryptography error: {0}")]
51    Cryptography(String),
52
53    /// Error related to message processing
54    #[error("Message error: {0}")]
55    Message(String),
56
57    /// Error related to policy evaluation
58    #[error("Policy error: {0}")]
59    Policy(String),
60
61    /// Error related to storage
62    #[error("Storage error: {0}")]
63    Storage(String),
64
65    /// IO errors
66    #[error("IO error: {0}")]
67    Io(#[from] std::io::Error),
68
69    /// Serialization errors
70    #[error("Serialization error: {0}")]
71    Serialization(String),
72
73    /// Feature not implemented
74    #[error("Feature not implemented: {0}")]
75    NotImplemented(String),
76
77    /// Key not found
78    #[error("Key not found: {0}")]
79    KeyNotFound(String),
80
81    /// DIDComm specific errors
82    #[error("DIDComm error: {0}")]
83    DIDComm(String),
84
85    /// DID Resolution error
86    #[error("DID Resolution error: {0}")]
87    DIDResolution(String),
88
89    /// JavaScript error (WASM)
90    #[cfg(target_arch = "wasm32")]
91    #[error("JavaScript error: {0}")]
92    JsError(String),
93
94    /// JavaScript resolver error (WASM)
95    #[cfg(target_arch = "wasm32")]
96    #[error("JavaScript resolver error: {0}")]
97    JsResolverError(String),
98
99    /// Serde JSON error
100    #[error("Serde JSON error: {0}")]
101    SerdeError(#[from] serde_json::Error),
102
103    /// Networking error
104    #[error("Networking error: {0}")]
105    Networking(String),
106
107    /// Runtime error
108    #[error("Runtime error: {0}")]
109    Runtime(String),
110}