add subcmd to repair some persistent state

This commit is contained in:
Charles Hall 2024-10-10 12:02:54 -07:00
parent 5be1e20eb4
commit 07d05fa1f9
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 131 additions and 0 deletions

View file

@ -48,6 +48,9 @@ pub(crate) enum Main {
#[error(transparent)]
CheckConfigCommand(#[from] CheckConfigCommand),
#[error(transparent)]
RepairCommand(#[from] RepairCommand),
}
/// Errors returned from the `serve` CLI subcommand.
@ -85,6 +88,28 @@ pub(crate) enum CheckConfigCommand {
Config(#[from] Config),
}
/// Errors returned from the `repair` 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 RepairCommand {
#[error("failed to load configuration")]
Config(#[from] Config),
#[error("failed to load or create the database")]
Database(#[source] crate::utils::error::Error),
#[error("failed to initialize services")]
InitializeServices(#[source] crate::utils::error::Error),
#[error("`server_name` change check failed")]
ServerNameChanged(#[from] ServerNameChanged),
#[error("repair \"{0}\" failed, restoring from a backup is recommended")]
Repair(&'static str, #[source] Box<dyn std::error::Error>),
}
/// Error generated if `server_name` has changed or if checking this failed
// Missing docs are allowed here since that kind of information should be
// encoded in the error messages themselves anyway.