Better api error handling (#790)

* API generation

* Updated code generation

* Updated test
This commit is contained in:
Tomas Della Vedova
2019-03-26 12:04:44 +01:00
committed by GitHub
parent 7d1c660f4e
commit 46bd14a36c
258 changed files with 1583 additions and 5074 deletions

View File

@ -26,6 +26,9 @@ function ESAPI (opts) {
assert(opts.ConfigurationError, 'Missing ConfigurationError class')
assert(opts.result, 'Missing default result object')
const { result } = opts
opts.handleError = handleError
const apis = {
bulk: lazyLoad('bulk', opts),
cat: {
@ -480,6 +483,11 @@ function ESAPI (opts) {
}
return apis
function handleError (err, callback) {
if (callback) return callback(err, result)
return Promise.reject(err)
}
}
// It's unlikely that a user needs all of our APIs,