Closed thyagab closed 6 years ago
What kind of promise implementation do you use? The style above only works for Bluebird. If you use native promises you need to use:
let errors = require('request-promise-native/errors')
// ...
.catch((err) => {
if (err instanceof errors.StatusCodeError) {
// Handle here
}
})
Thank you. I was using the above method before but later changed it to bluebird style. WIll revert to old one.
We have a request which is expected to return 409. Trying to use .catch(errors.StatusCodeError,function (errresponse) { //handle the error and return the error data } We are not able to catch the error here instead it is failing it with StatusCodeError: 409 - "" at new StatusCodeError (node_modules/request-promise-native/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (node_modules/request-promise-native/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (node_modules/request-promise-native/node_modules/request-promise-core/lib/plumbing.js:46:31) at Request.self.callback (node_modules/request/request.js:186:22) at Request. (node_modules/request/request.js:1163:10)
at IncomingMessage. (node_modules/request/request.js:1085:12)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
How do we handle catch in this case?