From 30a1369b91e60f282d2d02294a5cf55b55ad727b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 19 Jun 2015 12:10:45 +0200 Subject: [PATCH] drbd: improve error messages --- PVE/Storage/DRBDPlugin.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/PVE/Storage/DRBDPlugin.pm b/PVE/Storage/DRBDPlugin.pm index 7f79d12..91420da 100644 --- a/PVE/Storage/DRBDPlugin.pm +++ b/PVE/Storage/DRBDPlugin.pm @@ -72,16 +72,23 @@ sub check_drbd_res { die "got undefined drbd result\n" if !$rc; foreach my $res (@$rc) { - my ($code, $msg, $details) = @$res; + my ($code, $format, $details) = @$res; - return undef if $code == 0; + next if $code == 0; - $msg = "drbd error: got error code $code" if !$msg; + my $msg; + if (defined($format)) { + my @args = (); + push @args, $details->{$1} // "" + while $format =~ s,\%\((\w+)\),%,; + + $msg = sprintf($format, @args); + + } else { + $msg = "drbd error: got error code $code"; + } + chomp $msg; - - # fixme: add error details? - #print Dumper($details); - die "drbd error: $msg\n"; }