1use std::io;
2
3#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 #[error("failed to load .env file: {0}")]
7 Dotenv(#[from] dotenvy::Error),
8
9 #[error("invalid value {value:?} for environment variable {key}: {reason}")]
10 InvalidEnv {
11 key: String,
12 value: String,
13 reason: String,
14 },
15
16 #[error("failed to initialize logging: {0}")]
17 Logging(String),
18
19 #[error("failed to bind to {addr}: {source}")]
20 Bind {
21 addr: String,
22 #[source]
23 source: io::Error,
24 },
25
26 #[error("server error: {0}")]
27 Server(#[source] io::Error),
28
29 #[cfg(feature = "oidc")]
30 #[error("{0} is not set. {hint}", hint = crate::oidc::SETUP_HINT)]
31 MissingOidcSetting(&'static str),
32
33 #[cfg(feature = "oidc")]
34 #[error("OpenID Connect: {0}")]
35 Oidc(String),
36
37 #[cfg(feature = "database")]
38 #[error("database error: {0}")]
39 Database(#[from] toasty::Error),
40}
41
42pub type Result<T, E = Error> = std::result::Result<T, E>;