Reputation: 129
What is the difference between UnCaught Exception and Unhandled Promise Rejections in nodejs.
Upvotes: 7
Views: 4746
Reputation: 6718
Uncaught Exception
is when you throw
an error and did not catch anywhere.
Unhandled promise rejection
is similar, when you fail to catch a Promise.reject
.
It's about whether the error was generated by throw
or by Promise.reject
(more like error
generate from sync
vs async
process/code). Note that throw
inside an async
function is Promise.reject
as async
functions are wrapped inside Promise
for you
Read more about Promise
and async/await
Upvotes: 22