---
id: flow--throw-exception
title: "Error"
summary: "Throws a configurable error when a record reaches it. Use it to end a request with a failure (validation failed, not found, ...) that upstream error handling (Try catch, Retry, HTTP listener error response) reacts to."
audience: user
keywords: "input, message, code"
---
# Error

Throws a configurable error when a record reaches it. Use it to end a request with a failure (validation failed, not found, ...) that upstream error handling (Try catch, Retry, HTTP listener error response) reacts to.

## Pins

| Pin | Kind | Types | Description |
|---|---|---|---|
| Input | input | any | Every record raises the error. |

## Configuration

| Field | Type | Default | Description |
|---|---|---|---|
| `Message` | string (max 2048), exception selector | `Default` | Required. Error message. `Default` (any case) or empty generates "Exception occured on flow <flow> and component <component> at <date>". The editor offers predefined error types that fill `Message` and `Code`. |
| `Code` | integer | `500` | Required. Error code attached to the error, also used as the HTTP status code. `0` is replaced by `500`. |

## Behaviour

- Throws a `Viaducta.Plugin.Design.RecoverableFlowException` with `Message`, `Code`, and the flow and component name.
- The error travels back along the call chain to the components that called this one. The first component that handles errors receives it: a Try catch upstream routes the record to its `Catch` pin (metadata `Error` holds the exception); a Retry upstream retries; otherwise the error is logged as unhandled for this request.
- The error is recoverable: the flow keeps running and processes further records. (An `UnRecoverableFlowException`, raised by the system for e.g. failed expressions or missing connections, instead stops the flow and is not passed to Try catch.)
- The error is logged once by the system where it occurs.

## Notes

- `Message` and `Code` can be expressions, e.g. to include values from the record.
- The exception's "use code as HTTP status" flag is set: an HTTP listener that answers with the error uses `Code` as the status (for example `404`). Use HTTP status codes in `Code` when the flow serves HTTP.
- In the Try catch `Error` metadata, `FlowName` and `ComponentName` are set but `FlowId` and `ComponentId` are empty for errors from this component.
- The generated default message contains only the date, not the time.

## Example

```json
{ "Message": "Order not found", "Code": 404 }
```

Http listener → Try catch → (`Try`) Database reader → If (no rows) → **Error** ; (`Catch`) → Http response
