anytls_rs/util/
error.rs

1use thiserror::Error;
2
3/// AnyTLS protocol errors
4#[derive(Error, Debug)]
5pub enum AnyTlsError {
6    /// IO error from underlying system calls
7    #[error("IO error: {0}")]
8    Io(#[from] std::io::Error),
9
10    /// TLS-related error
11    #[error("TLS error: {0}")]
12    Tls(String),
13
14    /// Protocol violation or parsing error
15    #[error("Protocol error: {0}")]
16    Protocol(String),
17
18    /// Authentication failed (wrong password or credentials)
19    #[error("Authentication failed")]
20    AuthenticationFailed,
21
22    /// Stream ID not found in session
23    #[error("Stream not found: {0}")]
24    StreamNotFound(u32),
25
26    /// Session has been closed
27    #[error("Session closed")]
28    SessionClosed,
29
30    /// Invalid or malformed frame
31    #[error("Invalid frame: {0}")]
32    InvalidFrame(String),
33
34    /// Padding scheme error
35    #[error("Padding scheme error: {0}")]
36    PaddingScheme(String),
37
38    /// Configuration error
39    #[error("Configuration error: {0}")]
40    Config(String),
41}
42
43/// Result type alias
44pub type Result<T> = std::result::Result<T, AnyTlsError>;