Quick question; is there a list of all possible error return values?
ideally, a list of the HTTP status codes and a description of what the
returned JSON contains, but any information would be helpful.
Why am I asking? I'm looking into using elasticsearch for a project
which is built in python. pyes looks to be the best python client,
but it's current error handling works by following the algorithm:
- if 'ok' is in the result, it's not an error, so return it.
- if 'error' is in the result, look at its contents, and do string
pattern matching on them. Some patterns in the contents, with some
combinations of HTTP status codes 400 or 500, will cause an exception
to be raised. - if no patterns are matched, pyes will print the error contents to
stdout (!) and the just return them to the caller.
I'd like to improve this, and will start by making a generic exception
for unrecognised error contents, but it would be nice to be able to be
comprehensive in mapping possible error return values to appropriate
python exceptions.
It would be even nicer if elasticsearch produced a structured error
output, with a field containing the error type, and another field
containing any message which should be associated with the error, so
that string pattern matching didn't need to be used. (If there's an
option to turn that on, please let me know, it'd be lovely!)