From 6526709d4845864616eeea966a0c168b1d20ad96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 23 Apr 2021 13:00:47 +0200 Subject: [PATCH] file-restore: add context to b64-decode error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to make the following cryptic error: proxmox-file-restore failed: Error: Invalid byte 46, offset 5. more understandable: proxmox-file-restore failed: Error: Failed base64-decoding path '/root.pxar.didx' - Invalid byte 46, offset 5. when a user passes in a non-base64 path but sets `--base64`. Signed-off-by: Fabian Grünbichler --- src/bin/proxmox-file-restore.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-file-restore.rs b/src/bin/proxmox-file-restore.rs index 3d750152..bb8261bb 100644 --- a/src/bin/proxmox-file-restore.rs +++ b/src/bin/proxmox-file-restore.rs @@ -47,7 +47,8 @@ enum ExtractPath { fn parse_path(path: String, base64: bool) -> Result { let mut bytes = if base64 { - base64::decode(path)? + base64::decode(path.clone()) + .map_err(|err| format_err!("Failed base64-decoding path '{}' - {}", path, err))? } else { path.into_bytes() };