Widgets/Logic
Error Rescue Widget
Error Rescue Widget
A "Logic" type widget. Error Rescue Widget acts as an error handler that detects execution errors in child widgets and sends detailed error information to a dedicated rescue port. This widget is essential for building robust workflows that can gracefully handle and debug execution failures.
When an event is received through the input port, the Error Rescue Widget forwards it to its child widgets. If no error occurs, the event flows through normally. However, if any child widget encounters an execution error, the Error Rescue Widget catches the error and sends comprehensive error details to the error output port instead of allowing the error to propagate and potentially crash the workflow.
The widget captures both the error information (including stack traces and widget identifiers) and the original input event that triggered the execution chain. Importantly, the Error Rescue Widget can detect errors that occur multiple widgets down the pipeline from its position, not just direct child widgets.
Inputs
- Event (DataType: Anything) Accepts any type of data that will be forwarded to child widgets. The first event received will establish the data type for the output port. If an error occurs during processing anywhere in the downstream widget chain, the original event data is preserved in the error output for debugging purposes.
Outputs
-
Event (DataType: Dynamic - matches input type) Outputs the same data that was received at the input port, but only when no errors occur during child widget execution. The data type of this port dynamically matches the type of the last event received at the input.
-
Error (DataType: JsonObj) Outputs detailed error information when child widgets (or widgets further down the execution pipeline) encounter execution errors. The error object contains:
-
error: Error details including message, stack trace, and widget identificationmessage: The error messagetargetWidgetId: ID of the widget where the error occurredtargetPortName: Name of the port where the error occurredsourcePortName: Name of the source port that sent the datasourceWidgetId: ID of the widget that sent the datatargetWidgetType: Type of the widget where the error occurredsourceWidgetType: Type of the widget that sent the datastack: Complete error stack trace for debugging
-
inputEvent: The original event that arrived at the Rescue widget's input port (not necessarily the data that directly caused the error, since errors can occur multiple widgets down the pipeline)type: Data type of the event received at the Rescue widget's inputdata: The actual data that was received at the Rescue widget's input port
-
📌 Important Notes
- The Error Rescue Widget can detect errors that occur anywhere in the downstream execution chain, not just in direct child widgets
- The
inputEventin the error output represents the data that triggered the execution chain at the Error Rescue Widget level, which may be different from the data that directly caused the error
Example: Division with Error Handling
This example demonstrates how to use the Error Rescue Widget to handle division by zero errors in a mathematical workflow. The setup includes a custom Division widget that can throw errors when the divisor is zero, and the Error Rescue Widget catches these errors to prevent workflow crashes.
Drag the example onto the workspace to explore and experiment!
In this example:
- The Slider widget provides a dynamic divisor value ranging from
0to5 - The Value widget supplies a fixed dividend of
150 - The Script widget (division) performs the division operation and throws a descriptive error when the divisor is zero
- The Error Rescue widget catches any errors from the Script widget and routes detailed error information to its
erroroutput port - Finally, when the slider is set to a non-zero value, the division completes successfully and the result is displayed. However, when the slider is set to
0, the Script widget throws a "Division by zero is undefined" error, which is caught by the Error Rescue widget and displayed as error information instead of crashing the workflow.
📌 Additional Notes
- The Error Rescue Widget automatically stores the data type of the last received event to ensure type consistency on the output port
- The error output provides comprehensive debugging information, making it easier to identify and fix issues in complex workflows
- This widget is particularly useful in production workflows where you need to log errors without stopping the entire execution flow
Glossary
-
DataType
A Kemu-specific data type system that defines the structure and format of data flowing through widgets. Common types include
Anything,Number,String,JsonObj, andDynamic. -
execution chain
The sequence of widgets that receive and process data in a workflow, from input to output. The Error Rescue Widget can detect errors that occur anywhere in this chain, not just in direct child widgets.
-
execution pipeline
The complete path that data follows through connected widgets in a workflow, from input to output. Errors can occur at any point in this pipeline and be caught by upstream rescue widgets.
-
JsonObj
A Kemu data type that represents structured data in JSON format, containing key-value pairs and nested objects. Used for complex data structures like error information and configuration objects.