[pve-devel] [RFC_V2 pve-common] improve error handling.

Wolfgang Link w.link at proxmox.com
Mon May 22 11:35:22 CEST 2017


Get more information about the function where a timeout occurs.
---
 src/PVE/Tools.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index f84855d..df78bb3 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -26,6 +26,7 @@ use Net::DBus qw(dbus_uint32 dbus_uint64);
 use Net::DBus::Callback;
 use Net::DBus::Reactor;
 use Scalar::Util 'weaken';
+use Carp;
 
 # avoid warning when parsing long hex values with hex()
 no warnings 'portable'; # Support for 64-bit ints required
@@ -88,7 +89,7 @@ use constant {O_PATH    => 0x00200000,
 sub run_with_timeout {
     my ($timeout, $code, @param) = @_;
 
-    die "got timeout\n" if $timeout <= 0;
+    carp "got timeout" if $timeout <= 0;
 
     my $prev_alarm = alarm 0; # suspend outer alarm early
 
@@ -107,7 +108,7 @@ sub run_with_timeout {
 
 	alarm(0); # avoid race conditions
 
-	die $@ if $@;
+	carp $@ if $@;
     };
 
     my $err = $@;
-- 
2.1.4





More information about the pve-devel mailing list