Bluebird Raw Crash Error

I have the following code. And it works as expected without throwing an unhandled rejection error.

p = new Promise (fulfill, reject) ->
  reject new Error 'some error'

p.catch (error) ->
  console.log error

Now the second code example is causing a raw rejection error. Can someone explain to me why this happens when I am clearly dealing with the error.

p = new Promise (fulfill, reject) ->
  reject new Error 'some error'

p.then ->
  console.log 'ok'

p.catch (error) ->
  console.log error

Btw. I am testing chrome and bluebird v3.4.7.

+4
source share
2 answers

Per Bluebird , , , , , . , , . , " ". , ?

, ES6, -: Firefox , GC, Chrome ( ) .

Blue Bird Bluebird promises, .


p, , , - .

@DJ , . then , , p . , .then, , .

+1

Promises, Promise.

catch() then(), , .

, 1: catch() promises, .

2: , , 2- , . catch(), , then(), , 1-

. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch , catch

+1

Source: https://habr.com/ru/post/1667591/


All Articles