Error Handling in NodeJS (Complete Guide) | Node Tutorial

Sdílet
Vložit
  • čas přidán 3. 09. 2022
  • In this video you'll learn about what kinds of errors to handle in NodeJS, how to best handle them, and how to create your own custom errors.
    Code: github.com/nikitapryymak/node...
    Node Middleware: • What is middleware in ...
    Node Request Validation: • How to Validate Reques...
    Support Me: www.buymeacoffee.com/nikitadev
    Contact Me: nikitadev292@gmail.com
    #nodejs #javascript #api
  • Věda a technologie

Komentáře • 56

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

    Not only helped with JS error handling, but was a great introduction to error handling abstraction in general. This was a huge help!

  • @emkay2
    @emkay2 Před 9 měsíci +2

    The flow of your explanation just makes each step of the tutorial fall into place instantly. Thanks a lot!

  • @ljhastr
    @ljhastr Před rokem +15

    As someone who is learning Node and finished with the basics of mongoDB & mongoose, error handling was still a little unclear to me. This helped out massively, thank you! earned a sub.

    • @mma-dost
      @mma-dost Před rokem +2

      Same bro I was not able to clearly understand error handling.

    • @rohanshrestha8302
      @rohanshrestha8302 Před rokem

      @@mma-dost Hey bro can you suggest some sites or mentors you followed to learn node

  • @khatariinsaan5284
    @khatariinsaan5284 Před rokem +6

    You will definetely going to become a successful youtuber
    Just keep uploading Regularly !

  • @jomarkpangan9362
    @jomarkpangan9362 Před rokem

    Really great video. Clear, concise, fast. Just how I like it. subscribed!

  • @_V__.
    @_V__. Před 8 měsíci

    I just came across a similar implementation in an old project at work, shame I didn’t watch this before then, it would’ve helped me a lot. Awesome video!

  • @perenelm4988
    @perenelm4988 Před rokem +3

    Very straightforward explanation, thanks!

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

    This is the best error handling tutorial I have watched. Thanks

  • @mma-dost
    @mma-dost Před rokem

    Thanks I really watched many tutorial about this topic but none was like yours. Thanks sir 💯💯

  • @TrangBui-seeu
    @TrangBui-seeu Před rokem

    This video is really helpful and straightforward. I can now know what’s wrong with my project properly 😂

  • @itsmess1088
    @itsmess1088 Před rokem +1

    Super excellent video that really helps me a lot during refactoring the node project!! Thank you so much😃

  • @danielhaynes4747
    @danielhaynes4747 Před rokem +1

    Great video man! Keep up the good work and it will pay off! Thanks for the knowledge.

  • @VipulPatel-cd6sm
    @VipulPatel-cd6sm Před rokem +1

    Very well explained 👍.
    Thanks man.

  • @qgatss
    @qgatss Před 3 měsíci

    Thanks bro! This was really helpful, please keep uploading

  • @Aelsaan
    @Aelsaan Před rokem

    Thx a lot for this simple and efficient tutorial

  • @pytha12
    @pytha12 Před rokem +1

    Great job! 👏 Keep it up!

  • @plasthree
    @plasthree Před 2 měsíci

    This is the most beautiful way i have seen 😮. Thanks so much.

  • @Talel_kraiem
    @Talel_kraiem Před rokem +1

    Amazing tutorial ❤

  • @manassingh1793
    @manassingh1793 Před rokem

    You earned a sub man. What a fantastic video.

  • @anahitafakhravar1878
    @anahitafakhravar1878 Před rokem

    You helped me a lot. Thank you so much.

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

    Error handling strategies was unclear for me like the "this" keyword. tnx for giving us ideas regarding on effective error handling. keep it up ❤

  • @NoeVidal3
    @NoeVidal3 Před rokem

    Wow, thanks man! great video!!

  • @ycombinator765
    @ycombinator765 Před rokem +1

    bro please keep these quality videos coming. please

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

    Helpful video❤

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

    thank you, very helpful

  • @omsatpathy5455
    @omsatpathy5455 Před rokem

    very clearly explained.

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

    To the point. Subscribed👍👍

  • @prafulsrivastava8942
    @prafulsrivastava8942 Před rokem

    Great content!

  • @vignesh-xb5uz
    @vignesh-xb5uz Před rokem

    Lastly I found right one❣️

  • @aleksey6151
    @aleksey6151 Před rokem +2

    Amazing

  • @mma-dost
    @mma-dost Před rokem

    really great bro . respect++

  • @parthkolgiri7501
    @parthkolgiri7501 Před rokem

    Thanks man!

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

    very helpful

  • @baruntiwari8152
    @baruntiwari8152 Před 8 měsíci

    Awesome bro... panda gang op

  • @shiekkaleem4539
    @shiekkaleem4539 Před rokem

    I have 4 years experience and i was handling errors inside the controller...this is more Clear

  • @Programandoenc
    @Programandoenc Před rokem +1

    Hello! Thank you for the video! Is this the correct way to handle errors for a production environment ? I've read its a good approach to add graceful shutdown. What do you think ? and where or when should we add this ?

  • @hafidnurfirmansyah2839
    @hafidnurfirmansyah2839 Před rokem +2

    New subcriber

  • @27sosite73
    @27sosite73 Před rokem

    super!

  • @nelsonleone2508
    @nelsonleone2508 Před rokem

    Please which extension are you using ?
    The grey intellisense, seems like tabnine but i guess it's not

  • @rohanshrestha8302
    @rohanshrestha8302 Před rokem

    Hello there, I am kind of new to node, and as I'm learning all the videos seem to focus just on file read and write, events and http request, it that all of it in node, as documentation is not similar to laravel, it is a bit hard for me to switch please help

  • @himansuiii
    @himansuiii Před 2 měsíci

    Thankssssssssssssssss

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

    How do you export the actual AppError class and use it in those other files? You don't seem to do that but I'm having to do module.exports for that class then importing it in the other files??

    • @nikita-dev
      @nikita-dev  Před 5 měsíci

      I'm exporting the AppError class by doing:
      module.exports = AppError;
      then importing it by doing:
      const AppError = require("./AppError");
      I have a video about Node JS module imports/exports if you want to learn more about how this works!

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

      @@nikita-dev cheers. I emailed u too :P

  • @fadfooood
    @fadfooood Před rokem

    Why do I need to throw an error and then catch it?
    I mean if !user then return next(error);
    Is there any benefit or throwing and catching again?

    • @nikita-dev
      @nikita-dev  Před rokem +1

      Great question! The benefit is that all of your error handling code will be in one place -- the error handler middleware -- and it will reduce repetition. If you were to send the error response in your controllers (instead of passing the error on), you would have to write "res.status(400).send(msg)" every time. Once your routes become complex and there are multiple different checks, you would be repeating yourself a lot.
      It's much cleaner to just pass the error on to the error handler middleware, and then define the error response there (once).

    • @mma-dost
      @mma-dost Před rokem

      thanks for asking the doubt bro I was also used to think why not just send res.json(error).status(400) like that.

  • @zakaria2504
    @zakaria2504 Před rokem +3

    How about to write tryCatch function in such form:
    exports.tryCatch = fn => (req, res, next) => fn(req, res, next).catch(next);
    Looks cleaner

  • @abdulazeez.98
    @abdulazeez.98 Před rokem +4

    I had to dislike this video, the explanation was good but you covered Express error handling, not Node. By that I mean the ones which crash the node server.

  • @davorjovanovic7174
    @davorjovanovic7174 Před rokem +1

    Perfect explanation!

  • @27sosite73
    @27sosite73 Před rokem

    super!