1use ap_error::ap_error;
4use thiserror::Error;
5
6#[ap_error(flat)]
8#[derive(Debug, Error)]
9pub enum RemoteClientError {
10 #[error("Failed to connect to proxy: {0}")]
12 ConnectionFailed(String),
13
14 #[error("WebSocket error: {0}")]
16 WebSocket(String),
17
18 #[error("Proxy authentication failed: {0}")]
20 ProxyAuthFailed(String),
21
22 #[error("Invalid pairing code: {0}")]
24 InvalidPairingCode(String),
25
26 #[error("Noise protocol error: {0}")]
28 NoiseProtocol(String),
29
30 #[error("Handshake failed: {0}")]
32 HandshakeFailed(String),
33
34 #[error("Timeout: {0}")]
36 Timeout(String),
37
38 #[error("Secure channel not established")]
40 SecureChannelNotEstablished,
41
42 #[error("Client not initialized - call connect() first")]
44 NotInitialized,
45
46 #[error("Credential request failed: {0}")]
48 CredentialRequestFailed(String),
49
50 #[error("Serialization error: {0}")]
52 Serialization(String),
53
54 #[error("Session cache error: {0}")]
56 SessionCache(String),
57
58 #[error("Keypair storage error: {0}")]
60 KeypairStorage(String),
61
62 #[error("Channel closed")]
64 ChannelClosed,
65
66 #[error("Identity storage error: {0}")]
68 IdentityStorageFailed(String),
69
70 #[error("Rendezvous resolution failed: {0}")]
72 RendevouzResolutionFailed(String),
73
74 #[error("Invalid rendezvous code: {0}")]
76 InvalidRendevouzCode(String),
77
78 #[error("Fingerprint verification rejected by user")]
80 FingerprintRejected,
81
82 #[error("Invalid state: expected {expected}, got {current}")]
84 InvalidState { expected: String, current: String },
85
86 #[error("Session not found for fingerprint")]
88 SessionNotFound,
89}
90
91impl From<ap_noise::error::NoiseProtocolError> for RemoteClientError {
92 fn from(err: ap_noise::error::NoiseProtocolError) -> Self {
93 RemoteClientError::NoiseProtocol(err.to_string())
94 }
95}
96
97impl From<serde_json::Error> for RemoteClientError {
98 fn from(err: serde_json::Error) -> Self {
99 RemoteClientError::Serialization(err.to_string())
100 }
101}
102
103impl From<ap_proxy_protocol::ProxyError> for RemoteClientError {
104 fn from(err: ap_proxy_protocol::ProxyError) -> Self {
105 RemoteClientError::ConnectionFailed(err.to_string())
106 }
107}