Тёмный

16.16: try / catch with Promises - Topics of JavaScript/ES6 

The Coding Train
Подписаться 1,7 млн
Просмотров 65 тыс.
50% 1

Using try / catch with ES6 Promises, async, and await.
🔗 try...catch on MDN: developer.mozi...
🔗 Giphy API: developers.gip...
🔗 Wordnik API: developer.word...
🚂 Website: thecodingtrain....
💖 Patreon: / codingtrain
🛒 Store: www.designbyhu...
📚 Book recommendations: www.amazon.com...
💻 github.com/Cod...
🎥 For more videos on ES6/JavaScript: • 16: Topics of JavaScri...
🎥 For more Coding Challenges: • Coding Challenges
🔗 p5js.org/
🔗 processing.org
📄 Code of Conduct: github.com/Cod...

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 48   
@orangus01
@orangus01 5 лет назад
At 5:00 I think you were going for *if (!(results[i].img === null))*
@koopa9815
@koopa9815 2 года назад
Correct and forgive me if I'm wrong - but is the try/catch even necessary in this use case? Try/catch is used to catch errors, including those you might not expect. In this case, the error we are preparing for is if: results[ i ].image === null. But we handle that in the .then block by just not drawing the image if that happens, thus avoiding the problem altogether? I might be misunderstanding
@cyri11e
@cyri11e 6 лет назад
Great, crystal clear as usual and so fun, it’s really a pleasure to learn with you
@DarrenDignam
@DarrenDignam 6 лет назад
Any good examples of when it is appropriate to use try..catch then?
@minciNashu
@minciNashu 6 лет назад
Python, C++ and C# make use of exceptions as well.
@YameenYasin
@YameenYasin 5 лет назад
the most amazing thing with your videos is i enjoy and get to laugh a lot :D
@utkarshverma9838
@utkarshverma9838 3 года назад
Can you please share the github link for your Javscript Promises playlist's (Code implementation)
@owenizedd2830
@owenizedd2830 4 года назад
4:49 you know it’s always funny when you watch tutorial where the guy has excellent understanding of development but they still make this kind of mistakes 😂
@LittleRainGames
@LittleRainGames 6 лет назад
Try and catch is really good for server and database operations, like when you try to connect or grab data. Stuff that is out of your control and has a chance of throwing errors no matter what. So ya, pretty much exactly what you're doing. In these situations you can never use them too much. I came here to see what a promise is, didnt really get my answer though.
@WolfRose11
@WolfRose11 2 года назад
16.15 and 16.16 are out of order in the Topics of JavaScript Playlist
@driversteve9345
@driversteve9345 6 лет назад
I find that most examples online, although they demonstrate certain features and how-to wire them up, almost always they show how NOT to code in a professional way! I hardly ever see examples of exactly what professional developers would actually put into production code of the software they develop! That is severely lacking in the teaching world! If it's not the way you would code a professional made software yourself, then DON'T TEACH IT!!!
@Engineer9736
@Engineer9736 6 лет назад
That try catch is a last resort is just nonsense. It’s a key aspect of object orrientated programming. If you have a function that calls a function that calls a function, and that last function produces an error, you can just say throw new exception. All the 3 layers of functions will stop running and in the top function you can catch the error. Lesson you learn from this: Don’t trust oneliner statements from random people without them mentioning a source of information.
@OakJIM
@OakJIM 6 лет назад
Than again, especially in .NET try catch will perform really shitty, so its not a use or dont use scenario. But rather that you consider when to use it so that it makes sense, rather than just sticking to the convention of black or white.
@nobytes2
@nobytes2 5 лет назад
I use try/catch all the time I've written lots of internal cmd utilities for the company I work for. Errors are bound to happen, is just life, a try/catch is the most sane way to let the program keep going without crashing. I think what the chat meant is that not every situation needs a try/catch, of course you can have plain exceptions but well errors can be handled a thousand different ways. Try/catch is perfectly fine for every day use, I agree is nonsense to say limit how you use them.
@jakema4o
@jakema4o 3 года назад
Promises was second confusing thing for me after recursion. Now I got one, I feel so powerfull now.
@jimmykaushal9982
@jimmykaushal9982 Год назад
lol that was funny !img === null. I started laughing the moment he did that but great comeback missing on lunch. When I am doing the demo and screen sharing i can use that line lol
@andrearivera7065
@andrearivera7065 Год назад
Hey, new subscriber ♥ Understood you perfectly.
@网于睿
@网于睿 2 года назад
4:00 you can use try finally without catch
@gabrieljimenez6083
@gabrieljimenez6083 6 лет назад
I love this man.
@naut_nigel
@naut_nigel 6 лет назад
Gabriel Jiménez You are handsome. Do you have an IG? LMBO😂😅
@Eltopshottah
@Eltopshottah 2 года назад
I love the coding train
@kjaygopal5324
@kjaygopal5324 6 лет назад
Hey, can you let me what is a "strict mode" cuz my code is not working.
@toro705
@toro705 5 лет назад
Your videos are amazing, thanks for this
@rampage9530
@rampage9530 4 года назад
You deserve a big like, as usual !
@spiraldynamics6008
@spiraldynamics6008 3 года назад
Best tutorials
@ericzorn3735
@ericzorn3735 6 лет назад
I always love the videos because they are up beat and they always teach a lot
@Alex-rt7de
@Alex-rt7de 3 года назад
best ever
@ianprado1488
@ianprado1488 6 лет назад
@srinivasagupta6124
@srinivasagupta6124 4 года назад
Excellent tutorial. It is very easy to understand JS Promises by watching your videos witch some good examples. Not seen anyone the way Daniel enjoys his teaching. Thank you.
@johnydl
@johnydl 3 года назад
Did you ever make any tutorials on how to have something running async and something else running at the same time (like the loading bar) I'm trying to run a brute force computation and draw the most recent part of that to the screen, I think I'd like the brute force to run in a loop over and over async without having to worry about the draw FPS but I'm not sure how to do this. As it stands without the async I have to put the brute force inside the draw and either the draw doesn't run at the given frame rate or the brute force is slowed (it can only do a certain number of iterations per frame)
@johnclifforddevera658
@johnclifforddevera658 6 лет назад
Can you make a topic on using RxJS observables and subscriptions? Thanks.
@sharpfocus9572
@sharpfocus9572 3 года назад
Very useful videos , your way of learning is the best !! Please post the source code of these videos my friend .
@variable_0
@variable_0 4 года назад
This man helps me understand promises. but can I just point out that you sounded like donald duck?
@benjaminschultz6501
@benjaminschultz6501 2 года назад
Top notch, Daniel!! Thank you so much. This series cleared up a lot about promises for me.
@eduanlenine
@eduanlenine 6 лет назад
Thanks, Daniel!
@anthonytsang1961
@anthonytsang1961 5 лет назад
Very nice videos. Can you talk about how to implement streams in returning promises so that I can handle promises not at once?
@nagalokeshkanumoori7822
@nagalokeshkanumoori7822 6 лет назад
Then what is the best solution for the promise.all
@leonardomra
@leonardomra 5 лет назад
Great videos! Thanks!
@stevealmond7460
@stevealmond7460 6 лет назад
Dan.. I was looking at you p5.js introduction videos, which mention the p5js ide. But does that still exits? Which ide are you using here? .. sorry if that’s a stupid question
@TheCodingTrain
@TheCodingTrain 6 лет назад
The IDE I reference in my intro video no longer exists, however, a new one is coming out this summer. Stay tuned! Here is my current workflow: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-HZ4D3wDRaec.html Also: sublime text: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-UCHzlUiDD10.html atom editor: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-d3OcFexe9Ik.html brackets: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-nmZbhManVcY.html codepen: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5gfUgNpS6kY.html
@thesuperiorman8342
@thesuperiorman8342 3 года назад
Thank you for this series on promises. It's great.
@varunbhalla19
@varunbhalla19 6 лет назад
Best teacher
@Engineer9736
@Engineer9736 6 лет назад
Varun Bhalla A teacher that doesn’t know that a catch after a try is compulsory.. Sorry for being a critic, but that says something about his experience. It’s a nice man anyhow.
@wowatomica
@wowatomica 6 лет назад
@ Richard van Pukkem Have you even watched other videos on this channel? Dan is a genius with tons of experience.
@DarrenDignam
@DarrenDignam 6 лет назад
Dan is the archeytypal Dunning-Kruger coder.
@varunbhalla19
@varunbhalla19 6 лет назад
We still love him
@쿼쿼
@쿼쿼 6 лет назад
hey guys, can you tell me where i should start watch this you tube channel as you know it has so many contents. . i want to follow this one so .. . where is point of start??
@TheCodingTrain
@TheCodingTrain 6 лет назад
Try either of these playlists to start from scratch! ru-vid.complaylists?view=50&shelf_id=14&sort=dd ru-vid.complaylists?view=50&shelf_id=2&sort=dd
Далее
16.11: Promises Part 1 - Topics of JavaScript/ES6
24:53
5 Async + Await Error Handling Strategies
18:11
Просмотров 22 тыс.
▼ КАПИТАН НАШЁЛ НЕФТЬ В 🍑
33:40
Просмотров 457 тыс.
Вопрос Ребром - Серго
43:16
Просмотров 342 тыс.
16.12: Promises Part 2 - Topics of JavaScript/ES6
11:50
FizzBuzz: One Simple Interview Question
7:18
Просмотров 3,5 млн
JavaScript Promises Crash Course
24:03
Просмотров 36 тыс.
Tips For Using Async/Await in JavaScript
16:26
Просмотров 395 тыс.
16.14: async/await Part 2 - Topics of JavaScript/ES8
10:08
Microservices are Technical Debt
31:59
Просмотров 371 тыс.
Being Competent With Coding Is More Fun
11:13
Просмотров 84 тыс.