]> git.mjollnir.org Git - tks.git/commitdiff
Fixed the error handling from zebra when there is no description zebra
authorPenny Leach <penny@mjollnir.org>
Tue, 9 Mar 2010 14:08:56 +0000 (15:08 +0100)
committerPenny Leach <penny@mjollnir.org>
Tue, 9 Mar 2010 14:08:56 +0000 (15:08 +0100)
lib/Zebra.pm

index 8ae40ae8916c29b666f6712595861cedeb257b8f..b0bbed0e70e9e8d06aadffd53c41ae36b128a6cf 100644 (file)
@@ -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}";
                         }
                     }
                 }