2024-01-27 23:26:49 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2024-01-25 22:08:05 +01:00
|
|
|
use anyhow;
|
|
|
|
use thiserror::Error;
|
|
|
|
|
2024-01-25 22:33:48 +01:00
|
|
|
use crate::config::ApiAuth;
|
|
|
|
|
2024-01-25 22:08:05 +01:00
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
/// Bad IO operation
|
|
|
|
#[error("Bad IO operation")]
|
|
|
|
IO(#[from] std::io::Error),
|
2024-01-25 22:33:48 +01:00
|
|
|
#[error("Bad configuration file")]
|
|
|
|
Config(#[from] ConfigError),
|
2024-01-25 22:08:05 +01:00
|
|
|
#[error(transparent)]
|
|
|
|
Other(#[from] anyhow::Error),
|
|
|
|
#[error("Yaml error")]
|
2024-01-25 22:33:48 +01:00
|
|
|
SerdeYaml(#[from] serde_yaml::Error),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum ConfigError {
|
|
|
|
#[error("could not find git repository")]
|
|
|
|
GitRepoNotFound,
|
|
|
|
#[error("no \".autocrate.yaml\" or \".autocrate.yml\" found in repository root")]
|
|
|
|
NoYamlFile,
|
|
|
|
#[error("the autocrate config file is not a regular file (is it a directory?)")]
|
|
|
|
YamlFileIsNotFile,
|
|
|
|
#[error("api {0:?} provides both a `pass` and a `pass_file`")]
|
|
|
|
YamlApiAuthBothPass(ApiAuth),
|
2024-01-27 23:26:49 +01:00
|
|
|
#[error("{0} has 'enabled = false' in the yaml config")]
|
|
|
|
IsDisabledButUsed(&'static str),
|
|
|
|
#[error("password provided as file, but does not exist: {0}")]
|
|
|
|
PassFileDoesNotExist(PathBuf),
|
2024-01-25 22:08:05 +01:00
|
|
|
}
|