qubit_http/options/http_config_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 configuration error kind
11//!
12//! Category enum for [`crate::HttpConfigError`].
13//!
14
15use parse_display::{Display, FromStr as DeriveFromStr};
16use serde::{Deserialize, Serialize};
17
18/// Category of HTTP configuration errors.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, DeriveFromStr)]
20#[serde(rename_all = "snake_case")]
21#[display(style = "snake_case")]
22pub enum HttpConfigErrorKind {
23 /// A required configuration key is missing.
24 #[display("missing field")]
25 #[from_str(regex = "(?i)missing\\s+field")]
26 MissingField,
27 /// The value exists but cannot be converted to the expected type.
28 #[display("type error")]
29 #[from_str(regex = "(?i)type\\s+error")]
30 TypeError,
31 /// The value is present and well-typed but semantically invalid.
32 #[display("invalid value")]
33 #[from_str(regex = "(?i)invalid\\s+value")]
34 InvalidValue,
35 /// A header name or value cannot be converted to an HTTP header.
36 #[display("invalid header")]
37 #[from_str(regex = "(?i)invalid\\s+header")]
38 InvalidHeader,
39 /// An underlying `qubit-config` error occurred.
40 #[display("config error")]
41 #[from_str(regex = "(?i)config\\s+error")]
42 ConfigError,
43}