common_wal/
error.rs

1// Copyright 2023 Greptime Team
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 common_macro::stack_trace_debug;
16use snafu::{Location, Snafu};
17
18#[derive(Snafu)]
19#[snafu(visibility(pub))]
20#[stack_trace_debug]
21pub enum Error {
22    #[snafu(display("Failed to resolve endpoint {:?}", broker_endpoint))]
23    ResolveEndpoint {
24        broker_endpoint: String,
25        #[snafu(source)]
26        error: std::io::Error,
27        #[snafu(implicit)]
28        location: Location,
29    },
30
31    #[snafu(display("Failed to find ipv4 endpoint: {:?}", broker_endpoint))]
32    EndpointIPV4NotFound {
33        broker_endpoint: String,
34        #[snafu(implicit)]
35        location: Location,
36    },
37
38    #[snafu(display("Failed to read file, path: {}", path))]
39    ReadFile {
40        path: String,
41        #[snafu(source)]
42        error: std::io::Error,
43        #[snafu(implicit)]
44        location: Location,
45    },
46
47    #[snafu(display("Failed to add root cert"))]
48    AddCert {
49        #[snafu(source)]
50        error: rustls::Error,
51        #[snafu(implicit)]
52        location: Location,
53    },
54
55    #[snafu(display("Failed to read cert, path: {}", path))]
56    ReadCerts {
57        path: String,
58        #[snafu(source)]
59        error: std::io::Error,
60        #[snafu(implicit)]
61        location: Location,
62    },
63
64    #[snafu(display("Failed to read key, path: {}", path))]
65    ReadKey {
66        path: String,
67        #[snafu(source)]
68        error: std::io::Error,
69        #[snafu(implicit)]
70        location: Location,
71    },
72
73    #[snafu(display("Failed to parse key, path: {}", path))]
74    KeyNotFound {
75        path: String,
76        #[snafu(implicit)]
77        location: Location,
78    },
79
80    #[snafu(display("Failed to set client auth cert"))]
81    SetClientAuthCert {
82        #[snafu(source)]
83        error: rustls::Error,
84        #[snafu(implicit)]
85        location: Location,
86    },
87
88    #[snafu(display("Failed to load ca certs from system"))]
89    LoadSystemCerts {
90        #[snafu(source)]
91        error: std::io::Error,
92        #[snafu(implicit)]
93        location: Location,
94    },
95}
96
97pub type Result<T> = std::result::Result<T, Error>;