Comment on page
This is a middleware function that catches any errors in the controller methods and then passes these to a global error handler. This prevents you from having to use
try...catchin your application.
Errors are handled inside
When an error is caught, it will be logged to the console and a 500 status message returned to the client along with the error message.