Skip to main content

qubit_http/error/
http_error_kind.rs

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