PokeVideoPlayer v23.9-app.js-020924_
0143ab93_videojs8_1563605_YT_2d24ba15 licensed under gpl3-or-later
Views : 1,345,077
Genre: Science & Technology
License: Standard YouTube License
Uploaded At Jun 8, 2021 ^^
warning: returnyoutubedislikes may not be accurate, this is just an estiment ehe :3
Rating : 4.95 (1,002/79,306 LTDR)
98.75% of the users lieked the video!!
1.25% of the users dislieked the video!!
User score: 98.13- Masterpiece Video
RYD date created : 2022-04-09T14:16:37.494032Z
See in json
Top Comments of this video!! :3
And then you will end up with tower of ifs, when each function depends on previous results
You've just writed try catch using if statements nothing changed
What you can do is catch them all together
And make specific errors for each function and then switch through errors in catch block if you need to perform something for each error case
66 |
Such a quality of life improvement. I read this in an article once, when I was just starting out, and started writing it, just waiting for the other shoe to drop (I had to defend it before my boss, who was skeptical at first, even though he hated try catch and longed for the async.js days); cause why wasn't everyone doing this? No regrets!
3 |
Tips:
- Make the function take a promise as a parameter
- use "catch" method of the promise
- Call this function "to"
function to (promise) {
return promise.then(data => [null, data]).catch(err => [err])
}
const [err, data] = await to(fetch(/*thatUrl*/))
Notes: Dont need to have an async function or to use try-catch; its reusable for any function returning a promise; its a oneliner in a oneliner \o/
17 |
@gabriel.quagliano
3 years ago
Protip: Avoid the pyramid of doom by never indenting your code 🤙
5.2K |