1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Process-level errors (config, init, bind, serve).
use std::net::SocketAddr;
use std::path::PathBuf;
use crate::config::ConfigError;
/// Failure of the `o402` process.
#[derive(Debug, thiserror::Error)]
pub enum AppError {
/// Configuration could not be loaded or was invalid.
#[error(transparent)]
Config(#[from] ConfigError),
/// `o402 init` refused to overwrite an existing file.
#[error("'{}' already exists", path.display())]
AlreadyExists {
/// Path that already exists.
path: PathBuf,
},
/// `o402 init` could not write the example file.
#[error("failed to write '{}': {source}", path.display())]
Write {
/// Path that could not be written.
path: PathBuf,
/// Underlying IO error.
#[source]
source: std::io::Error,
},
/// TCP bind failed.
#[error("failed to bind {addr}: {source}")]
Bind {
/// Address passed to `TcpListener::bind`.
addr: SocketAddr,
/// Underlying IO error.
#[source]
source: std::io::Error,
},
/// The HTTP server returned an IO error.
#[error("server: {source}")]
Server {
/// Underlying IO error.
#[source]
source: std::io::Error,
},
/// A `.env` file existed but could not be parsed or read.
#[error("failed to load .env: {source}")]
Dotenv {
/// Underlying dotenvy error.
#[source]
source: dotenvy::Error,
},
/// An upstream HTTP client could not be constructed.
#[error("failed to build HTTP client for upstream '{name}': {source}")]
HttpClient {
/// `[[upstreams]]` name.
name: String,
/// Underlying reqwest error.
#[source]
source: reqwest::Error,
},
/// Prometheus recorder could not be installed.
#[error("metrics recorder: {0}")]
Metrics(String),
}