chiark / gitweb /
errors: Rename AnyhowDisplay and provide .d() and use it
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 20:33:41 +0000 (21:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 20:33:41 +0000 (21:33 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/error.rs
src/sshkeys.rs
src/utils.rs

index 65dc85ed7d61defdafab0b575fdc739d34b423c7..ea9f155445d464bb01392dfa04f086c867c1a55e 100644 (file)
@@ -52,7 +52,7 @@ pub enum InternalError {
   StringFormatting(#[from] fmt::Error),
   #[error("JSON deserialisation error: {0:?}")]
   JSONEncode(serde_json::Error),
-  #[error("Server error: {}", AnyhowFormat(&.0))]
+  #[error("Server error: {}", .0.d())]
   Anyhow(#[from] anyhow::Error),
   #[error("Game contains only partial data for player, or account missing")]
   PartialPlayerData,
index 83797f13f8d126feb216d1c96a011ba8203b1cce..7ddacc8d3d8c20e4ef38355dc6e5c75d019a2bd0 100644 (file)
@@ -80,7 +80,7 @@ pub struct AuthKeysManipError { }
 impl From<anyhow::Error> for AuthKeysManipError {
   fn from(ae: anyhow::Error) -> AuthKeysManipError {
     error!("authorized_keys manipulation error: {}: {}",
-           &config().authorized_keys, AnyhowFormat(&ae));
+           &config().authorized_keys, ae.d());
     AuthKeysManipError { }
   }
 }
index 01f9bd73ccdcbc976350e310bd773bbe5fa10e80..de0fced07409d8b9dcc6320e5f1fd66d1aa363fa 100644 (file)
@@ -644,8 +644,8 @@ impl<I,T> IndexVec<I,T> where I: index_vec::Idx {
 }
 
 #[derive(Debug)]
-pub struct AnyhowFormat<'a>(pub &'a anyhow::Error);
-impl Display for AnyhowFormat<'_> {
+pub struct AnyhowDisplay<'a>(pub &'a anyhow::Error);
+impl Display for AnyhowDisplay<'_> {
   #[throws(fmt::Error)]
   fn fmt(&self, f: &mut fmt::Formatter) {
     let mut delim = "";
@@ -670,6 +670,8 @@ impl anyhow::Error {
     Ok(())
   }
 
+  fn d(&self) -> AnyhowDisplay<'_> { AnyhowDisplay(self) }
+
   fn end_process(self, estatus: u8) -> ! {
     #[derive(Default,Debug)] struct Sol { any: bool }
     impl Sol {