Appearance
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.RecoverableFlowExceptionwithMessage,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
Catchpin (metadataErrorholds 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
MessageandCodecan 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
Codeas the status (for example404). Use HTTP status codes inCodewhen the flow serves HTTP. - In the Try catch
Errormetadata,FlowNameandComponentNameare set butFlowIdandComponentIdare 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