Handling Errors

Each API controller method call is wrapped in a HOC (higher order component) called use.

api.post('/api/account', use(accountController.create));

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.

Please refer to the error handling section in Gravity Web or Gravity Native to understand how these errors are handled on the client-side.

‚Äč