[pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context

Gabriel Goller g.goller at proxmox.com
Wed Feb 14 10:52:02 CET 2024


When printing an anyhow::Error using the "{}" formatter, only the outer
error will be printed. When using "{:#}" (pretty-print), the whole error
with all the contexts will be displayed.

Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
 pbs-client/src/pxar/create.rs                            | 2 +-
 pbs-client/src/pxar_backup_stream.rs                     | 2 +-
 proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index 6dac95d9..4cb095cd 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -105,7 +105,7 @@ impl std::error::Error for ArchiveError {}
 
 impl fmt::Display for ArchiveError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "error at {:?}: {}", self.path, self.error)
+        write!(f, "error at {:?}: {:#}", self.path, self.error)
     }
 }
 
diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs
index 22a6ffdc..61aee7c2 100644
--- a/pbs-client/src/pxar_backup_stream.rs
+++ b/pbs-client/src/pxar_backup_stream.rs
@@ -68,7 +68,7 @@ impl PxarBackupStream {
             .await
             {
                 let mut error = error2.lock().unwrap();
-                *error = Some(err.to_string());
+                *error = Some(format!("{:#}", err));
             }
         };
 
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index c2055222..d0e09e15 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -361,7 +361,7 @@ fn extract(
                 }
                 .await;
                 if let Err(err) = result {
-                    error!("pxar streaming task failed - {}", err);
+                    error!("pxar streaming task failed - {:#}", err);
                 }
             });
         } else if format == "tar" {
-- 
2.43.0





More information about the pbs-devel mailing list