Central Error Handling In NodeJS and TypeScript

Today's video is about error handling, and will be split into two parts.
The first are the principals behind error handling, these are applicable to other languages as well.
The second part is the example part, and is demonstrated using NodeJS.
Timestamps:
0:00 - Intro
0:20 - What will be in this video
0:50 - Why central error handling
1:18 - The goal of error handling
1:30 - First side of error handling - what do you do with the error
2:14 - The second side of error handling - what the app does with the error
2:30 - Programmer errors vs Operational errors
3:30 - Dealing with programmer errors, stateful vs stateless services
4:13 - Dealing with operational errors
4:34 - Sending the error to a logs platform
4:44 - NodeJS Code Example
5:12 - node-typescript-starter
5:33 - Creating your own error by extending Error
6:28 - Creating an error handler
7:15 - Creating a global error handler
8:40 - Creating multiple type of errors
9:05 - How to use the error handler in your app code
10:54 - Outro
If you like the video, like, comment, subscribe and share it with a friend/colleague.
node-type-script-starter repo:
github.com/yaircohendev/nodej...
Checkout WebDevLog newsletter - a Web Development newsletter focused on core, evergreen concepts for Front-End and Fullstack Developers:
webdevlog.com/
Coralogix:
coralogix.com/

Пікірлер: 16

  • @rockon7478
    @rockon74782 жыл бұрын

    very very helpful and highly insightful video, thank you very much for sharing!

  • @sankalp_choudhary
    @sankalp_choudhary2 жыл бұрын

    Very good video for handling error

  • @hurontermico8677
    @hurontermico8677 Жыл бұрын

    Thanks for the info! ❤

  • @hakouguelfen9187
    @hakouguelfen91872 жыл бұрын

    impressive, thanks

  • @eitanmizrachi4530
    @eitanmizrachi45302 жыл бұрын

    Gracias por la info

  • @asafrivni
    @asafrivni2 жыл бұрын

    Great video, Thanks!

  • @webdevlog

    @webdevlog

    2 жыл бұрын

    Thank you!

  • @art4thesoul
    @art4thesoul2 жыл бұрын

    אחלה תודה

  • @kaloyangeorgiev6824
    @kaloyangeorgiev68246 ай бұрын

    Amazing video, really helpful! I just want to ask, isn't the idea of Central Error Handling to remove a big amount of "try-catch"s in the code? In the way in the video, it looks like we are just transforming the errors for better usage and handling?

  • @webdevlog

    @webdevlog

    6 ай бұрын

    Hey, thanks a lot for the comment Yes the idea is both to reduce the amount of try and catch, and also give an opportunity for consistent error handling When it comes to things like validation errors you will still need to throw yourself because you want to tell the user something, but the part that handles it is centralized. In the video we are adding try and catch to places where it the program should fail and is not mandatory to do so, but we're doing that just to add some extra information to what happened, because we are sending these errors as logs. So to answer your question while it reduces the amount of try and catch in the code there will still be places where you'll want to add some context yourself and it depends on your specific situation

  • @galactusclb5733
    @galactusclb57332 жыл бұрын

    Very helpful video😍😍 Hey, Could you do a video about NodeJs with MySQL DB transactions and their error handling?

  • @webdevlog

    @webdevlog

    2 жыл бұрын

    Thank you! Adding the idea to the list 😉

  • @janaelmourad9681
    @janaelmourad9681 Жыл бұрын

    thanks for the great video , does it make sense to have the 'isOperational' property ? isn't going to be always true? (since we are not going to throw programmers errors)

  • @webdevlog

    @webdevlog

    Жыл бұрын

    It make sense because sometimes you want to throw operational errors so the middleware catches and logs it but will not restart the server (Because we know it’s not an error that could cause problems if we don’t restart)

  • @janaelmourad9681

    @janaelmourad9681

    Жыл бұрын

    @@webdevlog Thank you for your reply , i thought that programmer errors are unexpected so we are not going to know when to throw them (uncaught exceptions ), could you please give an example where we will need to throw programmer errors ,thanks in advance !

  • @webdevlog

    @webdevlog

    Жыл бұрын

    @@janaelmourad9681 Sorry I meant to write operational errors :)