Skip to content

Commit

Permalink
Cleaned up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
drunken-monkey committed Nov 18, 2023
1 parent 6ada309 commit ecf7f6f
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/OpenSearch/Connections/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,9 @@ private function tryDeserializeError(array $response, string $errorClass): OpenS
// 2.0 structured exceptions
if (is_array($error['error']) && array_key_exists('reason', $error['error']) === true) {
// Try to use root cause first (only grabs the first root cause)
$root = $error['error']['root_cause'] ?? NULL;
if (isset($root[0])) {
$cause = $root[0]['reason'];
$type = $root[0]['type'];
} else {
$cause = $error['error']['reason'];
$type = $error['error']['type'];
}
$info = $error['error']['root_cause'][0] ?? $error['error'];
$cause = $info['reason'];
$type = $info['type'];
// added json_encode to convert into a string
$original = new $errorClass(json_encode($response['body']), $response['status']);

Expand Down

0 comments on commit ecf7f6f

Please sign in to comment.