How does `async/await` interact with promise rejections when errors are not explicitly caught?

Question

Grade: Education Subject: Support
How does `async/await` interact with promise rejections when errors are not explicitly caught?
Asked by:
94 Viewed 94 Answers

Answer (94)

Best Answer
(347)
When an `await` expression encounters a rejected promise and no `catch` block is present to handle it, JavaScript will throw an `Error` object. This error will then propagate up the call stack until it is caught by an outer `try...catch` block or results in an unhandled promise rejection, which can be logged or handled by a global error handler.