1

Let's say I have the following function

const _error_handler = err => {
    console.log('[%s] %s - %s - %s', err.method.toUpperCase(), err.url, err.statusCode, err.statusMessage)
}

I want ALL my promises to automatically have that as it's catch block. So instead of doing

promise1
   .then(...)
   .catch(_error_handler)

promise2
   .then(...)
   .catch(_error_handler)

I want the .catch(_error_handler) to be implicit. Is this possible?

Kousha
  • 27,827
  • 41
  • 147
  • 262

0 Answers0