StringFormatting(#[from] fmt::Error),
#[error("JSON deserialisation error: {0:?}")]
JSONEncode(serde_json::Error),
- #[error("Server error: {0:?}")]
+ #[error("Server error: {}", AnyhowFormat(&.0))]
Anyhow(#[from] anyhow::Error),
#[error("Game contains only partial data for player, or account missing")]
PartialPlayerData,
pub struct AuthKeysManipError { }
impl From<anyhow::Error> for AuthKeysManipError {
fn from(ae: anyhow::Error) -> AuthKeysManipError {
- error!("authorized_keys manipulation error: {}: {:?}",
- &config().authorized_keys, ae);
+ error!("authorized_keys manipulation error: {}: {}",
+ &config().authorized_keys, AnyhowFormat(&ae));
AuthKeysManipError { }
}
}
}
}
+#[derive(Debug)]
+pub struct AnyhowFormat<'a>(pub &'a anyhow::Error);
+impl Display for AnyhowFormat<'_> {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) {
+ let mut delim = "";
+ self.0.for_each(&mut |s|{
+ write!(f, "{}{}", delim, s)?;
+ delim = ": ";
+ Ok(())
+ })?;
+ }
+}
+
#[ext(pub)]
impl anyhow::Error {
fn for_each(&self, f: &mut dyn FnMut(&str) -> fmt::Result) -> fmt::Result {