> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/166/throw-exception.md).

# Throw exception

{% hint style="info" %}
This page describes release **166 (Early)**. For the current Standard version, see [Throw exception](https://docs.appfarm.io/library/action-nodes/throw-exception).
{% endhint %}

The Throw exception action node stops the Action with a custom error. [Catch exception](https://docs.appfarm.io/library/action-nodes/catch-exception) can catch and handle it, so you can control what happens when something goes wrong.

If no Catch exception handles the error, the Action stops at this node.

### Usage

* **Data validation:** Stop when data from a form or an external endpoint is invalid.
* **Clear error messages:** Give the user a message that says what went wrong and what to do.
* **Logging and debugging:** Use the exception code to tell error types apart, for example in an [event log](https://docs.appfarm.io/how-to/logic-and-flow/event-log-design).

### Properties

<table><thead><tr><th width="213">Property</th><th>Description</th></tr></thead><tbody><tr><td><strong>Message</strong></td><td>Description of what went wrong. If the exception is not caught in a run triggered through an endpoint, the message is included as <code>message</code> in the error response.</td></tr><tr><td><strong>Exception code</strong></td><td>Identifies the kind of error, for example <code>ORDER_NOT_FOUND</code>. A Catch exception node can target this code to catch exactly this exception and let others pass through. If the exception is not caught in a run triggered through an endpoint, the code is included in the error response. It does not change the HTTP status code; set <strong>Response code</strong> for that.</td></tr><tr><td><strong>Response code</strong></td><td><em>Shown in Services and in Flows with an endpoint trigger.</em><br><br>The HTTP status code the endpoint responds with if the exception is not caught, for example <code>404 Not Found</code>. Only applies to runs triggered through an endpoint; other triggers ignore it. Default is <code>500 Internal Server Error</code>.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/166/throw-exception.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
