]> git.proxmox.com Git - pve-apiclient.git/commitdiff
client exception: try to avoid HTTP code duplication in error string
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 3 Dec 2020 14:55:53 +0000 (15:55 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 3 Dec 2020 14:55:53 +0000 (15:55 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/APIClient/Exception.pm

index 9e42bc9d2e80c34f3e38233a325a5ee8f019d602..c7c78c0b60023052488d547917b9f92c778f3e62 100644 (file)
@@ -99,8 +99,13 @@ sub raise_param_exc {
 
 sub stringify {
     my $self = shift;
-    
-    my $msg = $self->{code} ? "$self->{code} $self->{msg}" : $self->{msg};
+
+    my $msg = $self->{msg};
+    if (my $code = $self->{code}) {
+       if ($msg !~ /^\s*\Q$code\E[\s:,]/) { # avoid duplicating the error code heuristically
+           $msg = "$code $msg";
+       }
+    }
 
     if ($msg !~ m/\n$/) {