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] libsql::Error),
40
41 #[cfg(feature = "database")]
42 #[error("{0} is not set. {hint}", hint = crate::database::SETUP_HINT)]
43 MissingDatabaseUrl(&'static str),
44
45 #[cfg(feature = "database")]
46 #[error("statement {index} failed: {source}")]
47 Statement {
48 index: usize,
49 #[source]
50 source: libsql::Error,
51 },
52
53 #[cfg(feature = "database")]
54 #[error("migration `{0}` is registered more than once")]
55 DuplicateMigration(String),
56
57 #[cfg(feature = "database")]
58 #[error("cannot roll back batch {batch}: {reason}")]
59 RollbackRefused { batch: i64, reason: String },
60}
61
62pub type Result<T, E = Error> = std::result::Result<T, E>;