question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reject with error

See original GitHub issue

It is good practice to reject promises with an error object because they have stack traces.

When rejecting because of a bad status code, I suggest rejecting with an error object, e.g. BadStatusCodeError. You could then attach the response object to the error object so it can be accessed in a rejection handler.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

6reactions
helmuscommented, May 17, 2016

👍 Please raise the priority on this. This is not a feature, it’s a bug.

0reactions
truetercommented, Jul 13, 2016

Its been a month, can we please have this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise.reject() - JavaScript - MDN Web Docs
The static Promise.reject function returns a Promise that is rejected. For debugging purposes and selective error catching, it is useful to ...
Read more >
Error handling with promises - The Modern JavaScript Tutorial
In case of an error, the promise becomes rejected, and the execution should jump to the closest rejection handler. But there is none....
Read more >
JavaScript Promises - reject vs. throw - Stack Overflow
If it returns a rejected promise, the promise returned by the call to then is resolved to that promise (and will ultimately be...
Read more >
JavaScript promise reject() Method - GeeksforGeeks
It is used for debugging purposes and selective error catching. The catch() method can be used for logging the output of the reject()...
Read more >
prefer-promise-reject-errors - Pluggable JavaScript Linter
Error objects automatically store a stack trace, which can be used to debug an error by determining where it came from. If a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found