return 0;
}
- my $zresponse = from_json($res->content)->{command}{response};
+ my $zresponse = from_json($res->content);
- if ($zresponse && $zresponse->{success} && $zresponse->{success} eq 'false') {
- my @error = @{ from_json($res->content)->{command}{error} };
+ unless ($zresponse->{command}{response}{success} && $zresponse->{command}{response}{success} eq 'true') {
my $errorstr = '';
- foreach my $e (@error) {
- if (ref($e) eq 'HASH') {
- foreach my $key (keys %$e) {
- if ($key ne '@attributes') {
- $errorstr .= $e->{$key};
+ if ($zresponse->{command}{error}) {
+ my @error = @{ from_json($res->content)->{command}{error} };
+ foreach my $e (@error) {
+ if (ref($e) eq 'HASH') {
+ foreach my $key (keys %$e) {
+ if ($key ne '@attributes') {
+ $errorstr .= $e->{$key};
+ }
}
}
}
+ } elsif ($zresponse->{exception}{message}) {
+ $errorstr = $zresponse->{exception}{message};
}
$self->{_error} = qq(Failed to post timesheet data!, error if any was: $errorstr');
warn $self->{_error};