use std::io;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("failed to load .env file: {0}")]
Dotenv(#[from] dotenvy::Error),
#[error("invalid value {value:?} for environment variable {key}: {reason}")]
InvalidEnv {
key: String,
value: String,
reason: String,
},
#[error("failed to initialize logging: {0}")]
Logging(String),
#[error("failed to bind to {addr}: {source}")]
Bind {
addr: String,
#[source]
source: io::Error,
},
#[error("server error: {0}")]
Server(#[source] io::Error),
#[cfg(feature = "oidc")]
#[error("{0} is not set. {hint}", hint = crate::oidc::SETUP_HINT)]
MissingOidcSetting(&'static str),
#[cfg(feature = "oidc")]
#[error("OpenID Connect: {0}")]
Oidc(String),
#[cfg(feature = "database")]
#[error("database error: {0}")]
Database(#[from] libsql::Error),
#[cfg(feature = "database")]
#[error("{0} is not set. {hint}", hint = crate::database::SETUP_HINT)]
MissingDatabaseUrl(&'static str),
#[cfg(feature = "database")]
#[error("statement {index} failed: {source}")]
Statement {
index: usize,
#[source]
source: libsql::Error,
},
#[cfg(feature = "database")]
#[error("migration `{0}` is registered more than once")]
DuplicateMigration(String),
#[cfg(feature = "database")]
#[error("cannot roll back batch {batch}: {reason}")]
RollbackRefused { batch: i64, reason: String },
}
pub type Result<T, E = Error> = std::result::Result<T, E>;