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 related to missing configuration
38    #[error("Missing configuration: {0}")]
39    MissingConfig(String),
40
41    /// Error related to cryptographic operations
42    #[error("Crypto error: {0}")]
43    Crypto(String),
44
45    /// Error related to message processing
46    #[error("Message error: {0}")]
47    Message(String),
48
49    /// Error related to policy evaluation
50    #[error("Policy error: {0}")]
51    Policy(String),
52
53    /// Error related to storage
54    #[error("Storage error: {0}")]
55    Storage(String),
56
57    /// IO errors
58    #[error("IO error: {0}")]
59    Io(#[from] std::io::Error),
60
61    /// Serialization errors
62    #[error("Serialization error: {0}")]
63    Serialization(String),
64
65    /// Feature not implemented
66    #[error("Feature not implemented: {0}")]
67    NotImplemented(String),
68
69    /// DIDComm specific errors
70    #[error("DIDComm error: {0}")]
71    DIDComm(#[from] didcomm::error::Error),
72
73    /// DID Resolution error
74    #[error("DID Resolution error: {0}")]
75    DIDResolution(String),
76
77    /// JavaScript error (WASM)
78    #[cfg(target_arch = "wasm32")]
79    #[error("JavaScript error: {0}")]
80    JsError(String),
81
82    /// JavaScript resolver error (WASM)
83    #[cfg(target_arch = "wasm32")]
84    #[error("JavaScript resolver error: {0}")]
85    JsResolverError(String),
86
87    /// Serde JSON error
88    #[error("Serde JSON error: {0}")]
89    SerdeError(#[from] serde_json::Error),
90}