In NodeJS, I have some code like this:
function doSomethingAsync() {
return Promise.reject("error");
}
function main() {
doSomethingAsync().catch();
}
When I run this code, I get an UnhandledPromiseRejectionWarning
.
I know that making my calling function async
and await
ing doSomethingAsync
inside of a try
/catch
makes the error go away, but in this case, I don't want to add the extra complexity of making the function async and awaiting just to mute an error, so I'd prefer to use catch()
.
Why doesn't my method of error handling mute the error?