Error Handling
Learn about error handling in a Node.js application
We'll cover the following
Express comes with a default built-in error handler that deals with any errors that might arise in the application.
Handle errors centrally
Since we haven’t written custom error handlers to handle the errors passed to next()
in src/controllers/recipe.js
, the errors will be handled by the built-in error handler.
Let’s see what the default handler does. If a faulty path is visited where a recipe with a certain id
doesn’t exist, then an error is displayed in the browser, as shown below:
Get hands-on with 1200+ tech skills courses.