re: JavaScript async and await VIEW POST

FULL DISCUSSION
 

Not completely, as there is one case when it can be beneficial to use return await. Let's say you have three async functions, A,B and C, where A calls B, and B calls C.
Function B calls function C in a try-catch block. If B just returns the promise returned by function C than B puts the burden of error handling on function A as it's catch block will never be called. However if it uses return await C() and C rejects the promise, the erro will be handled by function B's catch block.
I might be making this waaay more complicated than it really is so here is Jake Archibald doing it much better than I did :)
jakearchibald.com/2017/await-vs-re...

 

Way too complicated lol. I just do this:

—-
async function test () {
await a
await b
Return c
}

Test().catch(handleError)

If C errors out, I still catch it with handleError.

code of conduct - report abuse