diff --git a/src/error.rs b/src/error.rs index 69d6b38f..1ada3bbb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,6 +2,7 @@ use std::{fmt, iter, path::PathBuf}; +use ruma::{OwnedServerName, OwnedUserId}; use thiserror::Error; use crate::config::ListenConfig; @@ -84,8 +85,15 @@ pub(crate) enum ServerNameChanged { #[error("failed to check if the admin bot exists")] AdminBotExists(#[source] crate::utils::error::Error), - #[error("`server_name` in the database and config file differ")] - Renamed, + #[error( + "`server_name` in the database ({0}) and config file ({1}) differ" + )] + Renamed(OwnedServerName, OwnedServerName), + + #[error( + "couldn't find {0} in the database, `server_name` must have changed" + )] + MissingAdminBot(OwnedUserId), #[error("failed to save the configured server_name")] SaveServerName(#[source] crate::utils::error::Error), diff --git a/src/service/globals.rs b/src/service/globals.rs index 0de48be0..00bbd7d9 100644 --- a/src/service/globals.rs +++ b/src/service/globals.rs @@ -332,7 +332,7 @@ impl Service { return Ok(()); } - return Err(Error::Renamed); + return Err(Error::Renamed(saved.clone(), config.to_owned())); } let non_zero_users = services() @@ -348,7 +348,7 @@ impl Service { // Fall back to checking against the admin bot user ID if non_zero_users && !admin_bot_exists { - return Err(Error::Renamed); + return Err(Error::MissingAdminBot(self.admin_bot_user_id.clone())); } // If the server_name wasn't saved and the admin bot user ID check