rewrite all the error display strings

Now that we log the source chain, there is no need to format the source
error in display. Also, a lot of these were terrible for other reasons.
This commit is contained in:
Olivia Lee 2024-12-14 02:23:32 -08:00
parent 05043f97a0
commit 45be146c14
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9

View file

@ -19,52 +19,46 @@ pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
#[allow(clippy::error_impl_error)]
pub(crate) enum Error {
#[cfg(feature = "sqlite")]
#[error(
"There was a problem with the connection to the sqlite database: \
{source}"
)]
#[error("error connecting to sqlite database")]
Sqlite {
#[from]
source: rusqlite::Error,
},
#[cfg(feature = "rocksdb")]
#[error(
"There was a problem with the connection to the rocksdb database: \
{source}"
)]
#[error("error connecting to rocksdb database")]
RocksDb {
#[from]
source: rocksdb::Error,
},
#[error("Could not generate image thumbnail.")]
#[error("error generating image thumbnail")]
GenerateThumbnail(#[source] image::error::ImageError),
#[error("Could not connect to server: {source}")]
#[error("error making request to server")]
Reqwest {
#[from]
source: reqwest::Error,
},
#[error("Could build regular expression: {source}")]
#[error("error building regular expression")]
Regex {
#[from]
source: regex::Error,
},
#[error("{0}")]
Federation(OwnedServerName, RumaError),
#[error("Could not do this io: {source}")]
#[error("federation request to {0} returned an error")]
Federation(OwnedServerName, #[source] RumaError),
#[error("IO error")]
Io {
#[from]
source: std::io::Error,
},
#[error("{0}")]
#[error("invalid server response: {0}")]
BadServerResponse(&'static str),
#[error("{0}")]
#[error("config error: {0}")]
BadConfig(&'static str),
#[error("{0}")]
#[error("invalid data in database: {0}")]
/// Don't create this directly. Use [`Error::bad_database`] instead.
BadDatabase(&'static str),
#[error("uiaa")]
#[error("UIAA error")]
Uiaa(UiaaInfo),
#[error("{0}: {1}")]
#[error("invalid request ({0}): {1}")]
BadRequest(ErrorKind, &'static str),
#[error("alias already exists")]
AliasConflict,
@ -74,11 +68,11 @@ pub(crate) enum Error {
Path(#[from] axum::extract::rejection::PathRejection),
#[error("{0}")]
AdminCommand(&'static str),
#[error("from {0}: {1}")]
#[error("error redacting event from {0}: {1}")]
Redaction(OwnedServerName, ruma::canonical_json::RedactionError),
#[error("unsupported room version {0}")]
UnsupportedRoomVersion(ruma::RoomVersionId),
#[error("{0} in {1}")]
#[error("inconsistent room state in {1}: {0}")]
InconsistentRoomState(&'static str, ruma::OwnedRoomId),
}