[pve-devel] [RFC_V2 pve-common] improve error handling.
Dietmar Maurer
dietmar at proxmox.com
Thu Jun 8 08:34:27 CEST 2017
I do not really want to modify run_with_timeout(); Instead, you can generate
a more verbose error message at the caller site.
Anyway, 'carp' is wrong (I assume you meant 'croak')
> On May 22, 2017 at 11:35 AM Wolfgang Link <w.link at proxmox.com> wrote:
>
>
> 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
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list