Skip to main content

haystack_client/
error.rs

1//! Client error types for the Haystack client library.
2//!
3//! [`ClientError`] covers all failure modes that can occur during client operations.
4
5/// Errors that can occur during Haystack client operations.
6#[derive(Debug, thiserror::Error)]
7pub enum ClientError {
8    /// SCRAM authentication handshake failed (invalid credentials, server rejected).
9    #[error("authentication failed: {0}")]
10    AuthFailed(String),
11
12    /// Server returned an error grid or non-200 HTTP status.
13    #[error("server error: {0}")]
14    ServerError(String),
15
16    /// Low-level HTTP or WebSocket transport failure.
17    #[error("transport error: {0}")]
18    Transport(String),
19
20    /// Failed to establish a connection (DNS, TCP, TLS handshake).
21    #[error("connection error: {0}")]
22    Connection(String),
23
24    /// Zinc/JSON/CSV encoding or decoding failure.
25    #[error("codec error: {0}")]
26    Codec(String),
27
28    /// The WebSocket or HTTP connection was closed unexpectedly.
29    #[error("connection closed")]
30    ConnectionClosed,
31
32    /// An operation exceeded the configured timeout duration.
33    #[error("request timed out after {0:?}")]
34    Timeout(std::time::Duration),
35
36    /// WebSocket concurrent request limit exceeded (backpressure).
37    #[error("too many in-flight requests")]
38    TooManyRequests,
39}