# Error Handling

## How to handle plugin errors?

* [ ] Use the [**On Error Condition**](#getting-errors) to get the latest error
* [ ] Retrieve the latest error from the [**Get Last Error** expression](#getting-errors)

<figure><img src="https://2351247042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9QQIPimQeOGE3C1HbWxf%2Fuploads%2F6RNDAl9jz1YRZu0WLVdj%2Fimage.png?alt=media&#x26;token=85cf1262-9109-4904-b161-94117ae63c5e" alt=""><figcaption></figcaption></figure>

## Getting errors&#x20;

The function is responsible for managing errors that occur during any plugin operation. When an error is detected, the function stores the error message in the internal variable. It then triggers the **On Error** condition, notifying the system that an error has occurred.

* **On Error Condition:** This condition is triggered whenever an error occurs in the plugin, allowing you to handle it within your Construct 3 project.
* **Get Last Error Expression:** The last error message can be retrieved using the **Get Last Error** expression, which returns the stored error message for debugging or user notifications.

This setup provides a consistent way to detect and respond to errors within your project.
