0

When I write promise in variable, I am getting unhandled rejection:

'use strict';

const Promise = require('bluebird');

const p = Promise.reject(new Error('qwerty'));

Unhandled rejection Error: qwerty at Object.

but when I'm doing the same thing with q, error is not thrown:

'use strict';

const q = require('q');

const p = q.reject(new Error('qwerty'));

Why does Promise.reject in bluebird work this way? I can't find information in documentation about this behavior.

Rostislav Shtanko
  • 704
  • 2
  • 9
  • 30
  • Possible duplicate of [Unhandled rejection error Bluebird](https://stackoverflow.com/questions/41817407/unhandled-rejection-error-bluebird) – Dez Oct 31 '17 at 19:05
  • Bluebird will fall back on native `Promise` if it is available which has this behavior. I'm not sure that `q` does the same sort of thing. – Explosion Pills Oct 31 '17 at 19:07
  • But it does, you can check it – Rostislav Shtanko Oct 31 '17 at 19:26
  • Perhaps because Bluebird has more warnings about likely problems in your code? You have a rejected promise with no `.catch()` handler. That's considered a problem. – jfriend00 Oct 31 '17 at 20:52

0 Answers0