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...catch in your application.
Errors are handled inside /server.js
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.