Skip to content

Commit

Permalink
get the root reason when available
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgalbu committed Jun 14, 2016
1 parent 7e84c25 commit 2a2aad2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/Elastica/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,18 @@ public function getError()
return $error;
}

$root_error = $error;
if (isset($error['root_cause'][0])) {
$error = $error['root_cause'][0];
$root_error = $error['root_cause'][0];
}

$message = $error['reason'];
if (isset($error['index'])) {
$message .= ' [index: '.$error['index'].']';
$message = $root_error['reason'];
if (isset($root_error['index'])) {
$message .= ' [index: '.$root_error['index'].']';
}

if (isset($error['reason'])) {
$message .= ' [reason: '.$error['reason'].']';
}

return $message;
Expand Down

0 comments on commit 2a2aad2

Please sign in to comment.