http_stat/
error.rs

1// Copyright 2025 Tree xie.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use snafu::Snafu;
16// Error enum for handling various error types in the configuration
17#[derive(Debug, Snafu)]
18pub enum Error {
19    #[snafu(display("uri parse error {source}"))]
20    Uri { source: http::uri::InvalidUri },
21    #[snafu(display("resolve error {source}"))]
22    Resolve {
23        source: hickory_resolver::ResolveError,
24    },
25    #[snafu(display("{category}, {message}"))]
26    Common { category: String, message: String },
27    #[snafu(display("io error {source}"))]
28    Io { source: std::io::Error },
29    #[snafu(display("timeout error {source}"))]
30    Timeout { source: tokio::time::error::Elapsed },
31    #[snafu(display("rustls error {source}"))]
32    Rustls { source: tokio_rustls::rustls::Error },
33    #[snafu(display("invalid dns name {source}"))]
34    InvalidDnsName {
35        source: tokio_rustls::rustls::pki_types::InvalidDnsNameError,
36    },
37    #[snafu(display("hyper error {source}"))]
38    Hyper { source: hyper::Error },
39    #[snafu(display("http error {source}"))]
40    Http { source: http::Error },
41}
42
43pub type Result<T> = std::result::Result<T, Error>;