#93 Error Handling in async function | Error Handling in Express | A Complete NODE JS Course

Sdílet
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

Komentáře • 30

  • @HamzahAhmad-db5cy
    @HamzahAhmad-db5cy Před rokem +14

    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

    • @shahidkhan4942
      @shahidkhan4942 Před rokem

      same situation

    • @propubggamer2222
      @propubggamer2222 Před 10 měsíci

      How next was called at 11:30 ad he didn't passed next in async fun of create product

    • @Leesdjo
      @Leesdjo Před měsícem

      I was using the express-async-handler from npm but don't sure how it works until now.

  • @Leesdjo
    @Leesdjo Před měsícem

    Thanks for the wonderful tutorial. Very detailed explanation.

  • @josephuzuegbu7431
    @josephuzuegbu7431 Před rokem +1

    I love this particular error handling method. Keep it up

  • @paulpna
    @paulpna Před rokem +1

    thank you very much for your videos. im learning a lot ! Greetings from Argentina!

  • @MrQVeeBoo
    @MrQVeeBoo Před rokem +1

    very nice, thank you for making this vdo. a bit complicated but with step by step explanation, you made it clearer. thx again.

  • @mahmoudkhalid86
    @mahmoudkhalid86 Před měsícem

    Took from me a lot to understand, thanks for explanation

  • @user-ed2fh1op6k
    @user-ed2fh1op6k Před 7 měsíci

    Nice explanation Thanks❤

  • @devkumar9889
    @devkumar9889 Před 7 měsíci

    Video is underrated 🔥🔥

  • @Hi2uGaming
    @Hi2uGaming Před 6 měsíci

    great explanation man

  • @technophoenix1536
    @technophoenix1536 Před 5 měsíci

    thank you very much for your videos

  • @Anonymous-cw7nx
    @Anonymous-cw7nx Před rokem +1

    This is an exact copy paste codes of Jonas Schmedtmann on Udemy. But thanks from India coz of your efforts 🇮🇳

    • @zakriayasir2060
      @zakriayasir2060 Před 11 měsíci +1

      but his way of teaching is far better than other youtubers

    • @zakriayasir2060
      @zakriayasir2060 Před 11 měsíci +1

      i have jonas course but i like to learn from here :)

    • @snehil3209
      @snehil3209 Před 4 měsíci +1

      content is same. so everybody copies from here and there but teaching style makes the diffrence. and his style is way better tha jonas

  • @user-dd7kw3ym5i
    @user-dd7kw3ym5i Před měsícem

    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?

  • @user-oz5no6br2q
    @user-oz5no6br2q Před rokem

    sir put video about multer

  • @adarshkhatri993
    @adarshkhatri993 Před rokem

    But after this is asyncerrorhandler function we are not using our custom error function??

  • @shubhamgoswami3722
    @shubhamgoswami3722 Před rokem

    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 ?

    • @vinaykumarkharwar177
      @vinaykumarkharwar177 Před 6 měsíci

      have you defined the route movie-stats in your router and pointed it to movieController.getMovieStats?

  • @chanelmalith
    @chanelmalith Před 5 měsíci

    after global the error hadler you didn't use CustomError class all the errors comming same status code spesify that

  • @vinaykumarkharwar177
    @vinaykumarkharwar177 Před 6 měsíci

    Hey, one question, why do we not need to return an async function in asyncErrorHandler and use await for function call?

    • @acupoflie
      @acupoflie Před 6 měsíci

      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.

    • @vinaykumarkharwar177
      @vinaykumarkharwar177 Před 6 měsíci

      @@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.

    • @acupoflie
      @acupoflie Před 6 měsíci

      @@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

  • @MultiDonet
    @MultiDonet Před rokem +2

    Lol, this course is a complete copy of the udemy course.

  • @tauhidxahmed
    @tauhidxahmed Před rokem +1

    copy of jonas schmedtmann course