Search code examples
node.jsexpresserror-handlingmiddleware

How to use return in express error handling


Is there a difference in an express application between these 2 pieces of code that calls an error handler?

return next(err); 
next(err); return;

Are they different or same and if different which one is correct/preferred?


Solution

  • next doesn't return anything, so these two statements are identical. But the first one is shorter.