From 0158208f43f0f614ceab9f928623b2bc6a36c017 Mon Sep 17 00:00:00 2001 From: Penny Leach Date: Sat, 30 May 2009 14:04:47 +0200 Subject: [PATCH] fixing error reporting in TKS Zebra perl module --- lib/Zebra.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Zebra.pm b/lib/Zebra.pm index 1e6c5df..31b4a1d 100644 --- a/lib/Zebra.pm +++ b/lib/Zebra.pm @@ -116,14 +116,27 @@ sub add_time { if ($res->is_error) { $self->{_error} = qq(Failed to post timesheet data!'); - return $self->{_error}; + warn $self->{_error}; + return 0; } my $zresponse = from_json($res->content)->{command}{response}; if ($zresponse && $zresponse->{success} && $zresponse->{success} eq 'false') { - $self->{_error} = qq(Failed to post timesheet data!'); - return $self->{_error}; + my @error = @{ from_json($res->content)->{command}{error} }; + my $errorstr = ''; + foreach my $e (@error) { + if (ref($e) eq 'HASH') { + foreach my $key (keys %$e) { + if ($key ne '@attributes') { + $errorstr .= $e->{$key}; + } + } + } + } + $self->{_error} = qq(Failed to post timesheet data!, error if any was: $errorstr'); + warn $self->{_error}; + return 0; } return 1; } -- 2.39.5