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::{
13 Display,
14 FromStr as DeriveFromStr,
15};
16use serde::{
17 Deserialize,
18 Serialize,
19};
20
21/// Category of HTTP errors.
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, DeriveFromStr)]
23#[serde(rename_all = "snake_case")]
24#[display(style = "snake_case")]
25pub enum HttpErrorKind {
26 /// URL is invalid or cannot be resolved.
27 InvalidUrl,
28 /// HTTP client construction failed.
29 BuildClient,
30 /// Proxy configuration is invalid.
31 ProxyConfig,
32 /// Connect timeout.
33 ConnectTimeout,
34 /// Read timeout.
35 ReadTimeout,
36 /// Write timeout.
37 WriteTimeout,
38 /// Whole-request timeout (client/request-level deadline).
39 RequestTimeout,
40 /// Transport-level request error.
41 Transport,
42 /// Non-success HTTP status.
43 Status,
44 /// Response decoding error.
45 Decode,
46 /// SSE protocol error.
47 SseProtocol,
48 /// SSE payload decoding error.
49 SseDecode,
50 /// Request was cancelled or interrupted.
51 Cancelled,
52 /// A single HTTP retry attempt exceeded its configured timeout.
53 RetryAttemptTimeout,
54 /// Total retry elapsed budget was exceeded before a retryable failure was recorded.
55 RetryMaxElapsedExceeded,
56 /// Retry stopped because the retry policy decided not to continue (abort).
57 RetryAborted,
58 /// Any other error.
59 Other,
60}