From: Thomas Lamprecht Date: Thu, 3 Dec 2020 14:55:53 +0000 (+0100) Subject: client exception: try to avoid HTTP code duplication in error string X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=50f793b9d1a950481a57e4231aeedfdeb859e089;p=pve-apiclient.git client exception: try to avoid HTTP code duplication in error string Signed-off-by: Thomas Lamprecht --- diff --git a/PVE/APIClient/Exception.pm b/PVE/APIClient/Exception.pm index 9e42bc9..c7c78c0 100644 --- a/PVE/APIClient/Exception.pm +++ b/PVE/APIClient/Exception.pm @@ -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$/) {