all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Laurențiu Leahu-Vlăducu" <l.leahu-vladucu@proxmox.com>
To: pbs-devel@lists.proxmox.com
Cc: "Laurențiu Leahu-Vlăducu" <l.leahu-vladucu@proxmox.com>
Subject: [pbs-devel] [PATCH proxmox 1/1] rest-server: Improved errors when panics occur and the panic message is a formatted (not static) string. This worked already for &str literals, but not for Strings.
Date: Tue, 21 Jan 2025 10:36:12 +0100	[thread overview]
Message-ID: <20250121093612.43094-3-l.leahu-vladucu@proxmox.com> (raw)
In-Reply-To: <20250121093612.43094-1-l.leahu-vladucu@proxmox.com>

Downcasting to both &str and String is also done by the Rust Standard
Library in the default panic handler. See:
https://github.com/rust-lang/rust/blob/b605c65b6eb5fa71783f8e26df69975f9f1680ee/library/std/src/panicking.rs#L777

Signed-off-by: Laurențiu Leahu-Vlăducu <l.leahu-vladucu@proxmox.com>
---
 proxmox-rest-server/src/worker_task.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index beec691e..45ee4e34 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -982,7 +982,10 @@ impl WorkerTask {
                         Ok(r) => r,
                         Err(panic) => match panic.downcast::<&str>() {
                             Ok(panic_msg) => Err(format_err!("worker panicked: {}", panic_msg)),
-                            Err(_) => Err(format_err!("worker panicked: unknown type.")),
+                            Err(panic) => match panic.downcast::<String>() {
+                                Ok(panic_msg) => Err(format_err!("worker panicked: {}", panic_msg)),
+                                Err(_) => Err(format_err!("worker panicked: cannot show error message due to unknown error type."))
+                            },
                         },
                     };
 
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

      parent reply	other threads:[~2025-01-21  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21  9:36 [pbs-devel] [PATCH proxmox/proxmox-backup 0/1] Improve errors when panics occur and the panic message is a formatted (not static) string Laurențiu Leahu-Vlăducu
2025-01-21  9:36 ` [pbs-devel] [PATCH proxmox-backup 1/1] backup-proxy and parallel_handler: Improved errors when panics occur and the panic message is a formatted (not static) string. This worked already for &str literals, but not for Strings Laurențiu Leahu-Vlăducu
2025-01-21 10:56   ` Gabriel Goller
2025-01-21 13:14     ` Laurențiu Leahu-Vlăducu
2025-01-21 13:17     ` Shannon Sterz
2025-01-21  9:36 ` Laurențiu Leahu-Vlăducu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250121093612.43094-3-l.leahu-vladucu@proxmox.com \
    --to=l.leahu-vladucu@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal