Routines for converting error responses to appropriate exceptions.

pyes.convert_errors.raise_if_error(status, result, request=None)

Raise an appropriate exception if the result is an error.

Any result with a status code of 400 or higher is considered an error.

The exception raised will either be an ElasticSearchException, or a more specific subclass of ElasticSearchException if the type is recognised.

The status code and result can be retrieved from the exception by accessing its status and result properties.

Optionally, this can take the original RestRequest instance which generated this error, which will then get included in the exception.