split out separate error type for serve command

This commit is contained in:
Benjamin Lee 2024-09-20 22:25:29 -07:00
parent 86515d53cc
commit 5315bac0c5
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
3 changed files with 14 additions and 3 deletions

View file

@ -60,7 +60,8 @@ pub(crate) struct ServeArgs {
impl Args {
pub(crate) async fn run(self) -> Result<(), error::Main> {
match self.command {
Command::Serve(args) => serve::run(args).await,
Command::Serve(args) => serve::run(args).await?,
}
Ok(())
}
}

View file

@ -44,8 +44,8 @@ use crate::{
utils::error::{Error, Result},
};
pub(crate) async fn run(args: ServeArgs) -> Result<(), error::Main> {
use error::Main as Error;
pub(crate) async fn run(args: ServeArgs) -> Result<(), error::ServeCommand> {
use error::ServeCommand as Error;
let config = config::load(args.config.config.as_ref()).await?;

View file

@ -40,6 +40,16 @@ impl fmt::Display for DisplayWithSources<'_> {
#[allow(missing_docs)]
#[derive(Error, Debug)]
pub(crate) enum Main {
#[error(transparent)]
ServeCommand(#[from] ServeCommand),
}
/// Errors returned from the `serve` CLI subcommand.
// Missing docs are allowed here since that kind of information should be
// encoded in the error messages themselves anyway.
#[allow(missing_docs)]
#[derive(Error, Debug)]
pub(crate) enum ServeCommand {
#[error("failed to load configuration")]
Config(#[from] Config),