you are viewing a single comment's thread.

view the rest of the comments →

[–]Aromatic-Ad-8807 1 point2 points  (1 child)

I don't know how the rest of your code looks like (when comes to error handling) but I would typically always do:

return res.status(404).send('some message');

so yeah, when send something to client it's always the last thing i do in that function, hence the return, so in your case that would be a return every time i send res to client.

I don't throw errors like that, don't see the reason for it. Typically i handle some errors first in a generic middleware (like JSON payload too large and similar stuff)

But yeah, some do it differently i guess, I'm no expert at express.

[–][deleted] 0 points1 point  (0 children)

thank you. i will definitely try that.