Wednesday 23 November 2016

Async and try/catch

I had this weird situation today, I was coding some random stuff and i used async/await and i had a little weird thing (in that moment) so i made and async function with promises etc, I called the function with await surrounded by try/catch for the reject of the promise but i misspelled 1 variable name and when i executed the code i got the error on try/catch and i verified the promise code etc, added some console logs for errors but the code inside promise was good, i was like (where's the error...) didn't used the e.stack (dumb move), so how do you guys make to know if the error on that try/catch was from the await or another function next to await or one misspelled variable (without the e.stack), i think await should have own error catching cuz using try/catch on await is weird for me, what's your opinion ?

Submitted November 23, 2016 at 05:42PM by 3nvi

No comments:

Post a Comment