Update body error check (#1472)

This commit is contained in:
Tomas Della Vedova
2021-05-20 16:14:51 +02:00
committed by GitHub
parent c34a6690ba
commit 507ed99e74

View File

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