In bluebird nodejs when should i use .error() instead of .catch.
What is difference between them. Please Explain in brief.
promise()
.then()
.error() OR
.catch()
.catch
:
.error
:
Many libraries don't throw error which is instance of Error
, so you are better off using .catch
Some library or user code may not throw error which is instanceOf Error
. Although it is recommended to throw Error
(or subclass) instance but there is nothing stopping to do otherwise.
From http://bluebirdjs.com/docs/api/catch.html:
Like
.catch
but instead of catching all types of exceptions, it only catches operational errors. Note, "errors" mean errors, as in objects that are instanceof Error - not strings, numbers and so on. See a string is not an error.
Some instances where error was not instance of Error
. They have been fixed.