pub enum Error {
Show 19 variants
Io(Error),
InvalidFrame(&'static str),
InvalidUtf8,
Protocol(&'static str),
ConnectionClosed,
MessageTooLarge,
FrameTooLarge,
InvalidHttp(&'static str),
HandshakeFailed(&'static str),
BufferFull,
WouldBlock,
ConnectionReset,
InvalidState(&'static str),
Closed(Option<CloseReason>),
InvalidCloseCode(u16),
Capacity(&'static str),
Compression(String),
ExtendedConnectNotSupported,
StreamReset,
}Expand description
WebSocket error types
Variants§
Io(Error)
I/O error from the underlying socket
InvalidFrame(&'static str)
Invalid WebSocket frame
InvalidUtf8
Invalid UTF-8 in text message
Protocol(&'static str)
Protocol violation
ConnectionClosed
Connection closed normally
MessageTooLarge
Message too large
FrameTooLarge
Frame too large
InvalidHttp(&'static str)
Invalid HTTP request
HandshakeFailed(&'static str)
Handshake failed
BufferFull
Buffer full (backpressure)
WouldBlock
Would block (non-blocking I/O)
ConnectionReset
Connection reset by peer
InvalidState(&'static str)
Invalid state
Closed(Option<CloseReason>)
Close frame received
InvalidCloseCode(u16)
Invalid close code
Capacity(&'static str)
Capacity exceeded
Compression(String)
Compression/decompression error
ExtendedConnectNotSupported
Extended CONNECT protocol not supported by server
StreamReset
Stream was reset by peer
Implementations§
Source§impl Error
impl Error
Sourcepub fn kind(&self) -> ErrorKind
pub fn kind(&self) -> ErrorKind
Get the error category/kind
Useful for metrics, logging, and error handling decisions.
Sourcepub fn is_fatal(&self) -> bool
pub fn is_fatal(&self) -> bool
Check if this error is fatal (connection cannot continue)
Fatal errors indicate the connection is broken and cannot be recovered. Non-fatal errors may allow the connection to continue after handling.
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this error is recoverable
Recoverable errors are transient and the operation may succeed if retried.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Check if this error is a timeout
Note: Timeout errors are typically wrapped by the caller using
tokio::time::timeout, but some transport errors may indicate timeouts.
Sourcepub fn is_connection_error(&self) -> bool
pub fn is_connection_error(&self) -> bool
Check if this error is a connection error
Sourcepub fn is_protocol_error(&self) -> bool
pub fn is_protocol_error(&self) -> bool
Check if this error is a protocol error
Sourcepub fn metric_name(&self) -> &'static str
pub fn metric_name(&self) -> &'static str
Get a metric-friendly name for this error
Returns a short, lowercase, underscore-separated string suitable for use in metrics labels.
Sourcepub fn suggested_http_status(&self) -> u16
pub fn suggested_http_status(&self) -> u16
Get a suggested HTTP status code for this error
Useful when converting WebSocket errors to HTTP responses during handshake or in HTTP/2/HTTP/3 contexts.