Loading video...

Video Failed to Load

Go Home

Stop writing Try Catch Blocks in your Express.js routes.

28,056 views • 11 months ago •via X (Twitter)

24 Comments

Gurbinder's profile picture
Gurbinder11 months ago

there is a better way...

Piyush Garg's profile picture
Piyush Garg11 months ago

👏🏻

Name cannot be blank's profile picture
Name cannot be blank11 months ago

It's kind of useless. You just create a custom error type holding the status and you do a middleware at the end handling them. You don't need to wrap every handler/controller with that.

Crystalzac's profile picture
Crystalzac11 months ago

Error handling middleware is a cleaner approach 🤷‍♂️

Angurī Wappā's profile picture
Angurī Wappā11 months ago

What the fuck language is this?

Tuhin Bhowmick (Sam)'s profile picture
Tuhin Bhowmick (Sam)11 months ago

So in spring boot world we have something called controller advice We throw the errors and write custom error handlers just once...

Yash Solanki's profile picture
Yash Solanki11 months ago

It would be good if we can send a custom error msg also so that would make it more reusable i guess. I love these short form videos. Keep making it 🙌

Divy Raj's profile picture
Divy Raj11 months ago

that sounds like solid advice

Affan.tsx's profile picture
Affan.tsx11 months ago

Very well explained sir

Ajay Singh's profile picture
Ajay Singh11 months ago

Haan hitesh sir ne Samjha diya backend series main

Pratham M's profile picture
Pratham M10 months ago

what is we need to send custom error for specific failures like failing to execute db-queries . its i think its we are writting same just giving fuction a wrapper of try catch

Bhavya Gupta's profile picture
Bhavya Gupta11 months ago

this is actually something which everyone should follow while working on the project

Komiriko's profile picture
Komiriko11 months ago

The first thing to stop is express js

Emmanuel Boluwatife's profile picture
Emmanuel Boluwatife11 months ago

The only issue I have with this is, sometimes you might want to handle errors differently for different routes. The use of closure is smart, Welldone 👏

Durmuş Demirtaş's profile picture
Durmuş Demirtaş11 months ago

Just migrate to express v5 and you are good to go. No need for custom implementatin.

Nisab Mohd's profile picture
Nisab Mohd10 months ago

a better way to do in express!

Abhishek's profile picture
Abhishek11 months ago

Gd

Adebakin Olamilekan Olujimi's profile picture
Adebakin Olamilekan Olujimi11 months ago

can you pls help those of us who dont understand indian with english translation on youtube videos been wanting to watch the system design tutorial but i just cant undersatnd what you saying

Aniket Baranwal's profile picture
Aniket Baranwal11 months ago

Ye to @Hiteshdotcom ki chai aur backend me seekh liya tha

Florin D's profile picture
Florin D11 months ago

This not solve the problem... you still using try catch

Okegbemi Joshua's profile picture
Okegbemi Joshua11 months ago

A more flexible way to achieve that.

‌‍ए एम् सी ए 🇮🇳²⁰²ˣ (मार्क 2 का परिवार)'s profile picture
‌‍ए एम् सी ए 🇮🇳²⁰²ˣ (मार्क 2 का परिवार)11 months ago

Ayu dark theme ?

Abhishek Mohan Kolge's profile picture
Abhishek Mohan Kolge10 months ago

Why not use express-async-errors?

Sarthak Srivastav's profile picture
Sarthak Srivastav10 months ago

Been using this template for a while now, asyncHandlers, ApiError and ApiResponse as utils, boosted my code readability and error handling capabilities multifold. Cool stuff

Related Videos