[Backport 7.x] Update body error check (#1474)

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2021-05-20 16:16:06 +02:00
committed by GitHub
parent 9a021f8445
commit 1e5d143d0c

View File

@ -90,7 +90,7 @@ class ResponseError extends ElasticsearchClientError {
super('Response Error')
Error.captureStackTrace(this, ResponseError)
this.name = 'ResponseError'
if (meta.body && meta.body.error && meta.body.status) {
if (meta.body && meta.body.error && meta.body.error.type) {
if (Array.isArray(meta.body.error.root_cause)) {
this.message = meta.body.error.type + ': '
this.message += meta.body.error.root_cause.map(entry => `[${entry.type}] Reason: ${entry.reason}`).join('; ')