# Debugging

```javascript
throw new Error("Error is:" +Value);
```

Error handling in After Effects can be achieved using JavaScript and the try-catch statement. Here's an example of how you can add error handling to your code:

```javascript
try {
  var path = thisComp.layer("SEG-1").content("Path 1").path;
  var trimPath = thisComp.layer("SEG-1").content("Trim Paths 1").end/100;
  var targetLayer = thisComp.layer("SEG-1");
  var point = path.pointOnPath(trimPath);

  targetLayer.toComp(Point);
} catch (e) {
  alert("An error occurred: " + e);
}

```

{% hint style="info" %}
In this example, the try block contains the code that may throw an exception. The catch block will be executed if an exception is thrown, and it will display an error message with the exception message. This allows you to handle exceptions gracefully and take appropriate actions in case of errors.
{% endhint %}


---

# 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://alex-kessling.gitbook.io/alex-kessling-motion-wiki/after-effects/ae-expressions/debugging.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.
