Skip to content

Commit

Permalink
proper handling of error when err object null, but status is not 200
Browse files Browse the repository at this point in the history
  • Loading branch information
ferronrsmith committed Dec 14, 2018
1 parent dea4160 commit 5ace347
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/transports/elasticsearch.js
Expand Up @@ -593,7 +593,14 @@ class elasticsearch {

aws4signer(payload, this.parent)
this.baseRequest(payload, (err, response) => {
if (err) { return callback(err) }
if (err) {
callback(err, [])
return
} else if (response.statusCode !== 200) {
err = new Error(response.body)
callback(err, [])
return
}

try {
const r = jsonParser.parse(response.body, this.parent)
Expand Down

0 comments on commit 5ace347

Please sign in to comment.