How can you pass an error to the error handler middleware?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can you pass an error to the error handler middleware?
Asked by:
58 Viewed 58 Answers
Responsive Ad After Question

Answer (58)

Best Answer
(195)
You pass an error to the error handler middleware by calling the `next()` function with an error object as its argument. For example, inside a route handler: `if (error) { return next(error); }`.