use shared::error::CoreError;
use sqlx::migrate::MigrateError;
use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
Core(#[from] CoreError),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("file not found: {path}")]
FileNotFound { path: PathBuf },
#[error("missing config key: `{key}`")]
_MissingConfig { key: String },
#[error("invalid value for `{key}`: {reason}")]
InvalidConfig { key: String, reason: String },
#[error("invalid argument `{arg}`: {reason}")]
_InvalidArg { arg: String, reason: String },
#[error("Validation failed")]
_InvalidAppConfig(Vec<Error>),
#[error(transparent)]
Yaml(#[from] serde_yaml::Error),
#[error(transparent)]
Sqlx(#[from] MigrateError),
#[error("HTTP request failed: {message}")]
_Http {
message: String,
#[source]
source: Box<dyn std::error::Error + Send + Sync + 'static>,
},
#[error("server returned {status}: {body}")]
_HttpStatus { status: u16, body: String },
#[error("command `{cmd}` failed with exit code {code}")]
_CommandFailed { cmd: String, code: i32 },
#[error("{0}")]
Other(String),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;