# Custom error handling

If you want to log errors to an application monitoring system, you can use a custom error handler.

Register this in `public/index.php` before you cann the `kuusamo` function.

```
Kuusamo\Vle\Exception\ErrorHandler::register(function($exception) {
    var_dump($exception->getMessage());
});
```

Foe example, lets say you wanted to integrate Rollbar. Install the Rollbar library using Composer and then add the following to your `index.php` file.

```
Rollbar\Rollbar::init([
    'access_token' => 'your_access_token',
    'environment' => 'production',
]);

Kuusamo\Vle\Exception\ErrorHandler::register(function($exception) {
    Rollbar\Rollbar::report_exception($exception);
});
```

Note that custom error handlers will only run when the project is in `production` mode. During development, the exception is presented to the developer.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kuusamo.org/technical/custom-error-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
