Skip to main content

bsv/auth/
error.rs

1//! Error types for the auth module.
2
3use thiserror::Error;
4
5/// Unified error type for all authentication operations.
6#[derive(Debug, Error)]
7pub enum AuthError {
8    /// Session not found for the given identity key.
9    #[error("session not found: {0}")]
10    SessionNotFound(String),
11
12    /// Peer is not authenticated.
13    #[error("not authenticated: {0}")]
14    NotAuthenticated(String),
15
16    /// Authentication handshake failed.
17    #[error("authentication failed: {0}")]
18    AuthFailed(String),
19
20    /// Received an invalid or malformed message.
21    #[error("invalid message: {0}")]
22    InvalidMessage(String),
23
24    /// Signature verification failed.
25    #[error("invalid signature: {0}")]
26    InvalidSignature(String),
27
28    /// Operation timed out.
29    #[error("timeout: {0}")]
30    Timeout(String),
31
32    /// Transport is not connected.
33    #[error("transport not connected: {0}")]
34    TransportNotConnected(String),
35
36    /// Nonce verification failed.
37    #[error("invalid nonce: {0}")]
38    InvalidNonce(String),
39
40    /// Required certificate is missing.
41    #[error("missing certificate: {0}")]
42    MissingCertificate(String),
43
44    /// Certificate validation failed.
45    #[error("certificate validation error: {0}")]
46    CertificateValidation(String),
47
48    /// Transport-level error.
49    #[error("transport error: {0}")]
50    TransportError(String),
51
52    /// Serialization or deserialization error.
53    #[error("serialization error: {0}")]
54    SerializationError(String),
55
56    /// Error from the wallet layer.
57    #[error("wallet error: {0}")]
58    Wallet(#[from] crate::wallet::WalletError),
59
60    /// Error from the primitives layer.
61    #[error("primitives error: {0}")]
62    Primitives(#[from] crate::primitives::PrimitivesError),
63}