Error Handling in NodeJS (Complete Guide) | Node Tutorial
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
Not only helped with JS error handling, but was a great introduction to error handling abstraction in general. This was a huge help!
The flow of your explanation just makes each step of the tutorial fall into place instantly. Thanks a lot!
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.
Same bro I was not able to clearly understand error handling.
@@mma-dost Hey bro can you suggest some sites or mentors you followed to learn node
You will definetely going to become a successful youtuber
Just keep uploading Regularly !
Really great video. Clear, concise, fast. Just how I like it. subscribed!
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!
Very straightforward explanation, thanks!
This is the best error handling tutorial I have watched. Thanks
Thanks I really watched many tutorial about this topic but none was like yours. Thanks sir 💯💯
This video is really helpful and straightforward. I can now know what’s wrong with my project properly 😂
Super excellent video that really helps me a lot during refactoring the node project!! Thank you so much😃
Great video man! Keep up the good work and it will pay off! Thanks for the knowledge.
thank you!
Very well explained 👍.
Thanks man.
Thanks bro! This was really helpful, please keep uploading
Thx a lot for this simple and efficient tutorial
Great job! 👏 Keep it up!
This is the most beautiful way i have seen 😮. Thanks so much.
Amazing tutorial ❤
You earned a sub man. What a fantastic video.
You helped me a lot. Thank you so much.
Error handling strategies was unclear for me like the "this" keyword. tnx for giving us ideas regarding on effective error handling. keep it up ❤
Wow, thanks man! great video!!
bro please keep these quality videos coming. please
Helpful video❤
thank you, very helpful
very clearly explained.
To the point. Subscribed👍👍
Great content!
Lastly I found right one❣️
Amazing
really great bro . respect++
Thanks man!
very helpful
Awesome bro... panda gang op
I have 4 years experience and i was handling errors inside the controller...this is more Clear
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 ?
New subcriber
super!
Please which extension are you using ?
The grey intellisense, seems like tabnine but i guess it's not
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
Thankssssssssssssssss
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??
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!
@@nikita-dev cheers. I emailed u too :P
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?
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).
thanks for asking the doubt bro I was also used to think why not just send res.json(error).status(400) like that.
How about to write tryCatch function in such form:
exports.tryCatch = fn => (req, res, next) => fn(req, res, next).catch(next);
Looks cleaner
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.
Perfect explanation!
thank you!
super!