From: Penny Leach Date: Tue, 9 Mar 2010 14:08:56 +0000 (+0100) Subject: Fixed the error handling from zebra when there is no description X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=refs%2Fheads%2Fzebra;p=tks.git Fixed the error handling from zebra when there is no description --- diff --git a/lib/Zebra.pm b/lib/Zebra.pm index 8ae40ae..b0bbed0 100644 --- a/lib/Zebra.pm +++ b/lib/Zebra.pm @@ -125,12 +125,15 @@ sub add_time { unless ($zresponse->{command}{response}{success} && $zresponse->{command}{response}{success} eq 'true') { my $errorstr = ''; if ($zresponse->{command}{error}) { - my @error = @{ from_json($res->content)->{command}{error} }; - foreach my $e (@error) { + my $error = $zresponse->{command}{error}; + if (ref($error) eq 'HASH') { + $error = [ $error ]; + } + foreach my $e (@{$error}) { if (ref($e) eq 'HASH') { foreach my $key (keys %$e) { if ($key ne '@attributes') { - $errorstr .= $e->{$key}; + $errorstr .= "$key: $e->{$key}"; } } }