JavaScript · Senior · Question 5 of 75

How do you globally track unhandled promise rejections in the browser?

Explanation

window.addEventListener('unhandledrejection', e => report(e.reason)) is the standard way to send such errors to monitoring. Synchronous unhandled errors are caught by the error event on window. There's no Promise.onError method.

Further reading

Problem with a question

JavaScript · Senior · question 5

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz