> 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/library/action-nodes/catch-exception.md).

# Catch exception

The Catch Exception Action Node is used to execute an action when an error occurs.

{% hint style="info" %}
Showroom: [Catch exception example](https://showroom.appfarm.app/action-nodes/catch-exception), with its setup in Appfarm Create ([register](https://showroom.appfarm.app/sign-up) for access).
{% endhint %}

When an error occurs in an action node, normal execution of the action will stop, and Appfarm will look for a matching Catch Exception Action Node after the failing node on the same level. A Catch Exception placed above the failing node is never used. If none matches, the error moves up one level, and the search continues after the enclosing node (for example, after the If or Foreach that contains the failing node), and so on. When it finds a catch block that meets the criteria of the error, the catch will execute whatever is defined inside it and then resume execution starting with the node directly after the catch (unless you use end execution or some other flow-changing action).

## Settings

### Catch all

If selected, all types of errors will trigger the execution of the action nodes inside the action.

### Exception types

If Catch all is not selected, you need to define the exception type(s) that shall be caught. Six different options are available, and some of them add their own properties.

#### Delete Constraint Exception

Used when there's a Delete Rule on a relation in the database, and the user tries to delete a parent. As long as objects in an object class have reference to a remote object class, deletions of referenced objects will not be allowed, i.e., if objects in the Project object class reference a Person object, it will not be possible to delete that Person object.

#### Web Request Error

Used when a web request returns a status code outside `2XX` that no [additional response](https://docs.appfarm.io/library/action-nodes/web-request.md#additional-responses) handles, or one handled by an additional response with the **Fail** outcome. If you don't want the action node to catch all web request errors, add the status codes to catch in **HTTP codes**. If none are set, all web request errors are caught.

When Web Request Error is selected, you can also set a **Result parser**: a function that parses the error data before it is mapped in [Result mapping](#result-mapping).

#### File Abort Exception

Used when a file operation is canceled, for example when the user closes the file picker without selecting a file. The error code is `17018`.

#### Custom Exception

Used when a Throw Exception Action Node returns an error. If you don't want the action node to catch all custom exceptions, add the codes to catch in **Custom codes**. If none are set, all custom exceptions are caught.

#### Flow timeout

Used when a Flow that runs asynchronously exceeds the timeout set on the Run Flow action node. The error is thrown at the node that is running, so a Catch Exception in the Flow can react before the run is stopped. The error code is `17035`.

#### Defined errors

Used when Appfarm returns an error. Add the error codes to catch in **Error codes**. Only those codes are caught; if none are set, no exceptions are caught, and Create shows a warning. Relevant Appfarm error codes are grouped below.

**Login ticket errors**

<table><thead><tr><th>Code</th><th width="224.81817626953125">Name</th><th>HTTP</th><th>Description</th></tr></thead><tbody><tr><td>10400</td><td>InvalidTokenError</td><td>400</td><td>Invalid token provided</td></tr><tr><td>10403</td><td>UserValidationError</td><td>403</td><td>Unauthorized</td></tr><tr><td>10410</td><td>LoginTicketNotFoundError</td><td>—</td><td>Unable to find ticket from token</td></tr><tr><td>10440</td><td>ExpiredLoginTicketError</td><td>—</td><td>Token expired</td></tr><tr><td>10500</td><td>InvalidLoginTicketDataError</td><td>—</td><td>Invalid data in Login Ticket</td></tr></tbody></table>

**Auth errors**

<table><thead><tr><th>Code</th><th width="258.45452880859375">Name</th><th>HTTP</th><th>Description</th></tr></thead><tbody><tr><td>11002</td><td>GoogleUserNotFoundError</td><td>401</td><td>Unable to find user connected to Google Account</td></tr><tr><td>11005</td><td>UserAccountNotFound</td><td>404</td><td>Unable to find Appfarm User Account</td></tr><tr><td>11010</td><td>MissingOtpReferenceError</td><td>403</td><td>Cannot login this device with one time password</td></tr><tr><td>11011</td><td>ExpiredOtpReferenceError</td><td>403</td><td>One time password has expired</td></tr><tr><td>11012</td><td>TooManyOtpTriesError</td><td>403</td><td>Too many retries</td></tr><tr><td>11013</td><td>InvalidPinError</td><td>401</td><td>Invalid PIN</td></tr><tr><td>11014</td><td>UserAccessDisabled</td><td>403</td><td>User is disabled</td></tr><tr><td>11040</td><td>AnonymousAppAccessError</td><td>403</td><td>Anonymous application access is not enabled</td></tr><tr><td>11041</td><td>LoginMetodDisabledError</td><td>403</td><td>Tried to use a disabled login method</td></tr><tr><td>11401</td><td>AuthenticationError</td><td>401</td><td>Authentication required</td></tr><tr><td>11403</td><td>AuthorizationError</td><td>403</td><td>User does not have sufficient permissions</td></tr><tr><td>11404</td><td>EnvironmentAuthorizationError</td><td>403</td><td>Operation not allowed from current environment</td></tr><tr><td>11500</td><td>InternalError</td><td>500</td><td>Internal error</td></tr></tbody></table>

**User errors**

<table><thead><tr><th>Code</th><th width="267.9090576171875">Name</th><th>HTTP</th><th>Description</th></tr></thead><tbody><tr><td>13005</td><td>MultipleUsersFoundError</td><td>500</td><td>Found more than one matching user</td></tr></tbody></table>

**Generic errors**

<table><thead><tr><th>Code</th><th width="293.9090576171875">Name</th><th width="102.818115234375">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>14002</td><td>AmpServerError</td><td>500</td><td>Unknown AMP server error</td></tr><tr><td>14003</td><td>NotImplementedError</td><td>500</td><td>Feature not implemented</td></tr><tr><td>14004</td><td>NotSupportedError</td><td>500</td><td>Feature not supported</td></tr><tr><td>14005</td><td>InputSanitationError</td><td>400</td><td>User input failed sanitation check</td></tr><tr><td>14006</td><td>ApiRequestError</td><td>500</td><td>Call to API failed</td></tr><tr><td>14007</td><td>UserAccountAlreadyExistException</td><td>409</td><td>User already in current solution</td></tr><tr><td>14008</td><td>ResourceGoneError</td><td>410</td><td>Resource is no longer available</td></tr><tr><td>14009</td><td>QuotaExceededException</td><td>422</td><td>Quota exceeded</td></tr><tr><td>14010</td><td>InvalidOperationError</td><td>400</td><td>Invalid operation</td></tr><tr><td>14011</td><td>NotEnabledError</td><td>403</td><td>Feature not enabled</td></tr><tr><td>14012</td><td>DeploymentConflictError</td><td>409</td><td>Cannot deploy due to conflicts</td></tr><tr><td>14400</td><td>InvalidEmailError</td><td>400</td><td>Invalid email address</td></tr><tr><td>14401</td><td>ClientOutOfSyncException</td><td>400</td><td>Client out of sync with server</td></tr><tr><td>14402</td><td>NetworkError</td><td>0</td><td>Network error occurred</td></tr><tr><td>14403</td><td>HttpError</td><td>0</td><td>Generic HTTP error</td></tr><tr><td>14404</td><td>ResourceNotFoundError</td><td>404</td><td>Resource not found</td></tr><tr><td>14408</td><td>TimeoutError</td><td>408</td><td>Request timeout</td></tr><tr><td>14900</td><td>InputValidationError</td><td>400</td><td>Invalid input data</td></tr><tr><td>14901</td><td>DataTypeError</td><td>400</td><td>Invalid datatype error</td></tr><tr><td>14902</td><td>RequiredDataError</td><td>400</td><td>Data cannot be nil</td></tr></tbody></table>

**AMP protocol errors**

<table><thead><tr><th>Code</th><th width="304.81817626953125">Name</th><th width="96.1817626953125">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>15002</td><td>AmpMessageError</td><td>400</td><td>Unknown AMP message error</td></tr><tr><td>15003</td><td>AmpProtocolError</td><td>406</td><td>Protocol error</td></tr><tr><td>15004</td><td>ServerRestartException</td><td>400</td><td>Server is restarting</td></tr></tbody></table>

**Model / function errors**

<table><thead><tr><th>Code</th><th width="315.72723388671875">Name</th><th width="86.091064453125">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>16001</td><td>UnexpectedDataTypeError</td><td>500</td><td>Unexpected datatype returned from function</td></tr><tr><td>16002</td><td>FunctionEvalError</td><td>500</td><td>Custom function value failed to evaluate</td></tr><tr><td>16003</td><td>FunctionEvalTimeoutError</td><td>500</td><td>Eval timeout — function took too long</td></tr><tr><td>16500</td><td>ModelParsingError</td><td>500</td><td>Failed to parse model</td></tr></tbody></table>

**Action node exceptions**

<table><thead><tr><th width="116.272705078125">Code</th><th width="341.5455322265625">Name</th><th width="94.0909423828125">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>17001</td><td>AppfarmCustomException</td><td>500</td><td>Thrown by Throw Exception nodes</td></tr><tr><td>17003</td><td>WebRequestException</td><td>500</td><td>Web request error</td></tr><tr><td>17004</td><td>GetUserMediaNotAllowedError</td><td>500</td><td>Camera/media access denied</td></tr><tr><td>17005</td><td>WebRequestTimeoutException</td><td>0</td><td>Web request timed out</td></tr><tr><td>17006</td><td>WebRequestAbortedException</td><td>0</td><td>Web request aborted</td></tr><tr><td>17007</td><td>SendEmailException</td><td>500</td><td>Send email failed</td></tr><tr><td>17008</td><td>SendEmailValidationException</td><td>400</td><td>Send email validation failed</td></tr><tr><td>17009</td><td>SendSMSValidationException</td><td>400</td><td>Send SMS validation failed</td></tr><tr><td>17011</td><td>WebPushValidationException</td><td>400</td><td>Web push validation failed</td></tr><tr><td>17013</td><td>CreateShortlinkException</td><td>500</td><td>Shortlink creation failed</td></tr><tr><td>17014</td><td>UserAccountException</td><td>500</td><td>User account error</td></tr><tr><td>17015</td><td>UserAccountValidationException</td><td>400</td><td>User account validation failed</td></tr><tr><td>17016</td><td>UploadFileFromURLException</td><td>500</td><td>Upload from URL failed</td></tr><tr><td>17017</td><td>UploadFileFromURLValidationException</td><td>400</td><td>Upload from URL validation failed</td></tr><tr><td>17018</td><td>FileAbortException</td><td>400</td><td>File operation aborted</td></tr><tr><td>17019</td><td>ActionNodeConfigurationError</td><td>400</td><td>Action node misconfigured by developer</td></tr><tr><td>17020</td><td>AgentRuntimeUnavailableError</td><td>500</td><td>Agent runtime not available in this context</td></tr><tr><td>17021</td><td>AgentLimitReachedError</td><td>500</td><td>Agent loop hit safety limit</td></tr><tr><td>17022</td><td>AgentToolInvocationError</td><td>400</td><td>LLM-supplied tool input violated contract</td></tr><tr><td>17023</td><td>AsyncFlowConcurrencyLimitError</td><td>429</td><td>Too many Flows running asynchronously at once</td></tr><tr><td>17024</td><td>UnpersistedFileBoundaryError</td><td>400</td><td>Unpersisted file object passed to or from a Flow; persist it first</td></tr><tr><td>17025</td><td>FlowConcurrencyError</td><td>409</td><td>Action set to no concurrency is already running</td></tr><tr><td>17026</td><td>FlowConcurrencyLockUnavailableError</td><td>503</td><td>Concurrency lock unavailable; try again</td></tr><tr><td>17027</td><td>WebPushNotConfiguredError</td><td>500</td><td>Web push is not configured on the server</td></tr><tr><td>17028</td><td>ImportDataException</td><td>500</td><td>Import data could not fetch or read the source</td></tr><tr><td>17029</td><td>AgentAttachmentError</td><td>400</td><td>Agent attachment could not be sent to the model</td></tr><tr><td>17030</td><td>AgentAttachmentFetcherUnavailableError</td><td>500</td><td>Agent attachments not available in this context</td></tr><tr><td>17031</td><td>AgentFilePersistUnavailableError</td><td>500</td><td>Agent could not save files in this context</td></tr><tr><td>17032</td><td>PreventDeviceSleepEnableError</td><td>500</td><td>Could not prevent device sleep</td></tr><tr><td>17033</td><td>AgentModelError</td><td>502</td><td>Agent model call failed</td></tr><tr><td>17034</td><td>AgentModelAccessUnavailableError</td><td>503</td><td>Agent model access unavailable</td></tr><tr><td>17035</td><td>FlowTimeoutError</td><td>408</td><td>Flow run exceeded its timeout</td></tr><tr><td>17036</td><td>FlowRunStoppedError</td><td>0</td><td>The Flow run was stopped with Manage Flow</td></tr><tr><td>17037</td><td>FlowRunIdConflictError</td><td>409</td><td>Run ID is already in use</td></tr><tr><td>17101</td><td>ActionNodeFailedError</td><td>0</td><td>Action node failed (runner-level)</td></tr><tr><td>17102</td><td>ActionNodeAbortedError</td><td>0</td><td>Action node aborted</td></tr><tr><td>17200</td><td>DebuggerResetError</td><td>400</td><td>Debugger reset</td></tr><tr><td>17201</td><td>DebuggerAbortedError</td><td>400</td><td>Execution aborted by debugger</td></tr></tbody></table>

**Validation errors**

<table><thead><tr><th>Code</th><th width="240.6363525390625">Name</th><th width="88.0908203125">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>1800</td><td>ValidationError</td><td>400</td><td>Generic validation error</td></tr></tbody></table>

**API service errors**

<table><thead><tr><th>Code</th><th width="272.0909423828125">Name</th><th width="103.8182373046875">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>31403</td><td>ActionNodeFailedError</td><td>400</td><td>Action Node Failed</td></tr><tr><td>31500</td><td>JobConcurrencyError</td><td>500</td><td>Cannot run multiple instances of job</td></tr><tr><td>31501</td><td>ActionNotFoundError</td><td>500</td><td>Unable to find action</td></tr></tbody></table>

**Client errors**

<table><thead><tr><th width="173.6363525390625">Code</th><th width="245.181884765625">Name</th><th width="121.5455322265625">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>30001</td><td>OnAppLoadFailedError</td><td>500</td><td>onAppLoad action failed</td></tr><tr><td>30002</td><td>RequestTimeoutError</td><td>408</td><td>Server did not respond in time</td></tr><tr><td>30003</td><td>ConnectionNotReadyError</td><td>503</td><td>Connection not ready</td></tr><tr><td>30004</td><td>PingTimeoutError</td><td>408</td><td>No ping response in time</td></tr><tr><td>30005</td><td>ApplyChangeError</td><td>500</td><td>Failed to apply operation bundle on server</td></tr><tr><td>30006</td><td>AbortError</td><td>0</td><td>Request aborted</td></tr></tbody></table>

**Client service errors**

<table><thead><tr><th>Code</th><th width="227.9090576171875">Name</th><th width="104.818115234375">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>32001</td><td>AppNotActiveError</td><td>400</td><td>App is not set active</td></tr><tr><td>32002</td><td>ClientOutOfSyncError</td><td>400</td><td>Client Out of Sync</td></tr><tr><td>32003</td><td>UnknownOperationError</td><td>500</td><td>Unknown Operation</td></tr></tbody></table>

**Data service errors**

<table><thead><tr><th width="87.90908813476562">Code</th><th width="283.90911865234375">Name</th><th width="98.36358642578125">HTTP</th><th>Description</th></tr></thead><tbody><tr><td>34002</td><td>UniquenessConstraintError</td><td>500</td><td>Uniqueness constraint violated</td></tr><tr><td>34003</td><td>MissingRequiredFieldsError</td><td>500</td><td>Required fields missing</td></tr><tr><td>34004</td><td>InsufficientCreatePermissionError</td><td>403</td><td>Insufficient create permission</td></tr><tr><td>34005</td><td>InsufficientAggregatePermissionError</td><td>403</td><td>Insufficient aggregate permission</td></tr><tr><td>34006</td><td>InsufficientUpdatePermissionError</td><td>403</td><td>Insufficient update permission</td></tr><tr><td>34007</td><td>InsufficientDeletePermissionError</td><td>403</td><td>Insufficient delete permission</td></tr><tr><td>34008</td><td>UpdateReadOnlyError</td><td>403</td><td>Attempted to update read-only field</td></tr><tr><td>34009</td><td>UpdateObjectError</td><td>500</td><td>Update object failed</td></tr><tr><td>34010</td><td>PersistError</td><td>500</td><td>Persist failed</td></tr><tr><td>34011</td><td>DeleteConstraintException</td><td>500</td><td>Unable to delete object (child references exist)</td></tr><tr><td>34012</td><td>PropertyValidationError</td><td>400</td><td>Property validation failed</td></tr><tr><td>34013</td><td>ConflictError</td><td>409</td><td>Conflict</td></tr><tr><td>34014</td><td>InsufficientReadPermissionError</td><td>403</td><td>Insufficient read permission</td></tr><tr><td>34015</td><td>BadRequestError</td><td>400</td><td>Bad request</td></tr><tr><td>34016</td><td>DocumentLimitExceededError</td><td>400</td><td>Document limit exceeded</td></tr></tbody></table>

**Messaging errors**

<table><thead><tr><th width="99.3636474609375">Code</th><th width="281.18182373046875">Name</th><th>HTTP</th><th>Description</th></tr></thead><tbody><tr><td>35001</td><td>SmsDisabledException</td><td>—</td><td>SMS is disabled</td></tr><tr><td>35002</td><td>DailyQuotaExceededException</td><td>—</td><td>Daily quota exceeded</td></tr><tr><td>35003</td><td>MonthlyQuotaExceededException</td><td>—</td><td>Monthly quota exceeded</td></tr></tbody></table>

### Result mapping

Result mapping might be used to map error data to Data Sources. The following data is available:

| Key                | Data                        |
| ------------------ | --------------------------- |
| **httpStatusCode** | Error code                  |
| **code**           | Internal Appfarm error code |
| **name**           | Error name                  |
| **message**        | Error message               |
| **body**           | Web Request response data   |

The data is returned as a JSON object, and body data can be mapped by setting RootPath to `body.theKeyYouWant`. If you use a **Result parser** (Web Request Error only), the available data is what the parser returns.

{% code collapsedlinecount="10" %}

```
{
    httpStatusCode: integer,
    code: integer,
    name: String,
    message: String,
    body: {}
}
```

{% endcode %}


---

# 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/library/action-nodes/catch-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.
