#93 Error Handling in async function | Error Handling in Express | A Complete NODE JS Course
Vložit
- čas přidán 20. 04. 2023
- In this lecture, we are going to re-factor our code and learn how we can catch errors in an async function and handle it, without using try-catch block.
ASP.NET Core GitHub Repo: github.com/manojjha86/ASP.NET...
NODE JS Course GitHub Repo: github.com/manojjha86/NODE-JS
I came across the asyncErrorHandler while doing Brad Traversy's course. Unfortunately, he didn't explain what was actually happening in the asyncErrorHandler. I tried reading blog posts and watching other videos but still couldn't figure it out. This video however, explained it very clearly. Thanks a bunch for such a detailed explanation
same situation
How next was called at 11:30 ad he didn't passed next in async fun of create product
I was using the express-async-handler from npm but don't sure how it works until now.
Thanks for the wonderful tutorial. Very detailed explanation.
I love this particular error handling method. Keep it up
thank you very much for your videos. im learning a lot ! Greetings from Argentina!
very nice, thank you for making this vdo. a bit complicated but with step by step explanation, you made it clearer. thx again.
Took from me a lot to understand, thanks for explanation
Nice explanation Thanks❤
Video is underrated 🔥🔥
great explanation man
thank you very much for your videos
This is an exact copy paste codes of Jonas Schmedtmann on Udemy. But thanks from India coz of your efforts 🇮🇳
but his way of teaching is far better than other youtubers
i have jonas course but i like to learn from here :)
content is same. so everybody copies from here and there but teaching style makes the diffrence. and his style is way better tha jonas
How can I pass my own message error that isn't defined in our schema? for example I don't want the error that come from mongoose.
Also the statusCode will always be a "500" cause "error.statusCode" will always be undefined. So are the "asyncHandler" supposed to be always return an internal server errror and not client error?
look here 6:01 now how do you pass the 400 status code that you removed?
sir put video about multer
But after this is asyncerrorhandler function we are not using our custom error function??
There is one bug i am facing after implementing the globalerrorhandler and asyncErrorHandler is if i give a get request with api/v1/movies/movie-statss it shows me 200 ok status code in response but no data . And I created the route for movie-stats . Same if I tried movie-status it shows me 200 ok resp with no data but when i hit movie-statsss with 3's it shows me it cant be change to ObjectId . Is there any reason behind it or I have done error ?
have you defined the route movie-stats in your router and pointed it to movieController.getMovieStats?
after global the error hadler you didn't use CustomError class all the errors comming same status code spesify that
Hey, one question, why do we not need to return an async function in asyncErrorHandler and use await for function call?
because if you don't return a function, to createMovie variable will be assigned a result from that function, but we call createMovie variable as a function in routes file so it must be a function in order to call it, so that we return a complete function that createMovie don't be a result of some function, but a function itself.
@@acupoflie In the confusion, I misrepresented my question possibly. The question is why we don't need to insert async between the return keyword and function. I guess the answer is because we send an async function there, and the promise is handled well.
@@vinaykumarkharwar177 it is because the function which we pass the asyncErrorHandler is already async function and that function returns a promise or rejection promise in result, we handle the success promise inside of the that function, and only catch method so it is rejection promise, we handle it in asyncErrorFunction in order to don't do it in every async function which we send request, i hope it was clear
Lol, this course is a complete copy of the udemy course.
yes but, his way of teaching is soooo good
copy of jonas schmedtmann course