Skip to main content

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