open_agent_id/error.rs
1//! Error types for the Open Agent ID SDK.
2
3use thiserror::Error;
4
5/// Unified error type for all Open Agent ID operations.
6#[derive(Debug, Error)]
7pub enum Error {
8 /// The DID string is malformed or does not conform to the `did:oaid:{chain}:{address}` format.
9 #[error("invalid DID: {0}")]
10 InvalidDid(String),
11
12 /// An Ed25519 key is malformed or the wrong length.
13 #[error("invalid key: {0}")]
14 InvalidKey(String),
15
16 /// A signing operation failed (e.g. no private key available).
17 #[error("signing error: {0}")]
18 Signing(String),
19
20 /// Signature verification failed.
21 #[error("verification error: {0}")]
22 Verification(String),
23
24 /// A registry API call failed.
25 #[cfg(feature = "client")]
26 #[error("API error: {0}")]
27 Api(String),
28
29 /// Communication with the oaid-signer daemon failed.
30 #[cfg(feature = "signer")]
31 #[error("signer error: {0}")]
32 Signer(String),
33
34 /// An invalid URL was provided for canonical construction.
35 #[error("invalid URL: {0}")]
36 InvalidUrl(String),
37
38 /// JSON serialization or deserialization failed.
39 #[error("JSON error: {0}")]
40 Json(#[from] serde_json::Error),
41}