update error enum names

This commit is contained in:
naskya 2024-06-21 09:10:28 +09:00
parent a09555b7d9
commit e807488471
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
5 changed files with 10 additions and 3 deletions

View file

@ -16,8 +16,9 @@ pub(crate) enum Commands {
Validate,
}
/// Errors that can happen in `config` subcommand
#[derive(thiserror::Error, Debug)]
pub(crate) enum Error {
pub(crate) enum ConfigError {
#[error(transparent)]
Update(#[from] update::UpdateError),
#[error(transparent)]
@ -89,7 +90,7 @@ fn next_revision() -> Result<Option<Revision>, RevisionCheckError> {
Ok(next_revision)
}
pub(crate) async fn run(command: Commands) -> Result<(), Error> {
pub(crate) async fn run(command: Commands) -> Result<(), ConfigError> {
match command {
Commands::Update { revision } => update::run(revision).await?,
Commands::Validate => validate::run()?,

View file

@ -10,6 +10,7 @@ use chrono::Local;
use color_print::cprintln;
use std::{fs, io};
/// Errors that happen in `config update` subcommand
#[derive(thiserror::Error, Debug)]
pub(crate) enum UpdateError {
#[error(transparent)]

View file

@ -15,6 +15,7 @@ use std::{
use url::Url;
use yaml_rust::{Yaml, YamlLoader};
/// Errors that can happen in `config update v1` subcommand
#[derive(thiserror::Error, Debug)]
pub(crate) enum Error {
#[error("failed to parse the old config file ({})", OLD_CONFIG_PATH)]
@ -29,6 +30,7 @@ pub(crate) enum Error {
InvalidUrl(#[from] url::ParseError),
}
/// Errors that can happen while reading `.config/default.yml`
#[derive(thiserror::Error, Debug)]
pub(crate) enum ReadYamlConfigError {
#[error(transparent)]
@ -39,6 +41,7 @@ pub(crate) enum ReadYamlConfigError {
InvalidConfig(String),
}
/// Errors that can happen while writing `config/{server,client}.toml`
#[derive(thiserror::Error, Debug)]
pub(crate) enum WriteTomlConfigError {
#[error("failed to serialize the new server config into TOML format")]

View file

@ -8,6 +8,7 @@ use color_print::cprintln;
use std::{fs, io::Read};
use validator::Validate;
/// Errors that can happen in `config validate` subcommand
#[derive(thiserror::Error, Debug)]
pub(crate) enum ValidationError {
#[error(transparent)]

View file

@ -5,10 +5,11 @@ mod version;
use clap::{Parser, Subcommand};
/// Errors that can happen in any commands
#[derive(thiserror::Error, Debug)]
pub(crate) enum Error {
#[error(transparent)]
Config(#[from] config::Error),
Config(#[from] config::ConfigError),
}
#[derive(Parser)]