Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the root reason from elasticsearch's json when available #1111

Merged
merged 1 commit into from
Jun 15, 2016

Conversation

maxgalbu
Copy link
Contributor

@maxgalbu maxgalbu commented Jun 14, 2016

Sometimes elasticsearch (i'm using 2.3.3) returns an error with two reasons:

{
  "error": {
    "root_cause": [
      {
        "type": "index_creation_exception",
        "reason": "failed to create index"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "synonym requires either `synonyms` or `synonyms_path` to be configured"
  },
  "status": 400
}

But the current code uses only the "root_cause" reason, leaving me with an exception that says "failed to create index" and not much else. This change uses the "root" reason key if it exists.

@maxgalbu maxgalbu changed the title Get the root reason from elasicsearch's json when available Get the root reason from elasticsearch's json when available Jun 14, 2016
if (isset($error['root_cause'][0])) {
$error = $error['root_cause'][0];
$root_error = $error['root_cause'][0];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use $rootError for the name here to adhere to our naming standard?

@ruflin
Copy link
Owner

ruflin commented Jun 15, 2016

LGTM. One minor comment about the naming. Could you please also update the CHANGELOG.md? And if possible, rebase it on master. That will fix the broken 5.4 build.

@ruflin
Copy link
Owner

ruflin commented Jun 15, 2016

@maxgalbu Oh, Github started to send notifications for new commits. Not sure if this is complete yet, but you missed the CHANGELOG.md part ;-)

@maxgalbu
Copy link
Contributor Author

maxgalbu commented Jun 15, 2016

you're right, I had a brief moment of pause at work so I did the quick fix :)

@ruflin ruflin merged commit 45ee2de into ruflin:master Jun 15, 2016
@ruflin
Copy link
Owner

ruflin commented Jun 15, 2016

Merged. Thanks a lot for the improvement. Unfortunately I already made the 3.2.1 release today in the morning, so it will go into the next minor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants