1

I have seen something in our codebase while refactoring coffeescript->js and I am a bit anxious if I break something if I change it, I haven't seen return Promise.reject(new Error('not found')); before

// This is old code
somePromise()
  .then(function (res) {
    if ((res == null)) { return Promise.reject(new Error('not found')); }
    return 'found'
  })

somePromise()
  .then(function (res) {
    if ((res == null)) { throw new Error('not found'); }
    return 'found'
  })

suchcodemuchwow
  • 848
  • 2
  • 9
  • 27
  • 5
    Hello, does this answer your question ? https://stackoverflow.com/questions/33445415/javascript-promises-reject-vs-throw – Namysh Aug 12 '20 at 08:17
  • FWIW, the answers to the linked question didn't cover one very minor aspect of this, so [I've done that now](https://stackoverflow.com/questions/33445415/javascript-promises-reject-vs-throw/63373036#63373036). – T.J. Crowder Aug 12 '20 at 08:48

0 Answers0