Skip to main content

qubit_http/error/
http_error_kind.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9//! HTTP error category enum.
10
11use parse_display::{Display, FromStr as DeriveFromStr};
12use serde::{Deserialize, Serialize};
13
14/// Category of HTTP errors.
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, DeriveFromStr)]
16#[serde(rename_all = "snake_case")]
17#[display(style = "snake_case")]
18pub enum HttpErrorKind {
19    /// URL is invalid or cannot be resolved.
20    InvalidUrl,
21    /// HTTP client construction failed.
22    BuildClient,
23    /// Proxy configuration is invalid.
24    ProxyConfig,
25    /// Connect timeout.
26    ConnectTimeout,
27    /// Read timeout.
28    ReadTimeout,
29    /// Write timeout.
30    WriteTimeout,
31    /// Whole-request timeout (client/request-level deadline).
32    RequestTimeout,
33    /// Transport-level request error.
34    Transport,
35    /// Non-success HTTP status.
36    Status,
37    /// Response decoding error.
38    Decode,
39    /// SSE protocol error.
40    SseProtocol,
41    /// SSE payload decoding error.
42    SseDecode,
43    /// Request was cancelled or interrupted.
44    Cancelled,
45    /// A single HTTP retry attempt exceeded its configured timeout.
46    RetryAttemptTimeout,
47    /// Total retry elapsed budget was exceeded before a retryable failure was recorded.
48    RetryMaxElapsedExceeded,
49    /// Retry stopped because the retry policy decided not to continue (abort).
50    RetryAborted,
51    /// Any other error.
52    Other,
53}