> For the complete documentation index, see [llms.txt](https://docs.usegravity.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usegravity.app/gravity-server/handling-errors.md).

# Handling Errors

Each [API](/gravity-server/rest-api.md) controller method call is wrapped in a HOF (higher-order function) called `use`**.**

```javascript
// node.js
api.post('/api/account', use(accountController.create));

// next.js
export const GET = withApiRoute('owner', 'account.read', accountController.get);
```

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.

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.&#x20;

{% hint style="info" %}
Errors are [automatically logged](/gravity-server/logging.md) and accessible any time in [Mission Control](/mission-control/introduction.md).
{% endhint %}

Please refer to the error handling section in [Gravity Web](/gravity-web/handling-errors.md) or [Gravity Native](/gravity-native/handling-errors.md) to understand how these errors are handled on the client side.&#x20;
