Class TryCatchExecutor
java.lang.Object
ai.nervemind.app.executor.TryCatchExecutor
- All Implemented Interfaces:
NodeExecutor
Executor for the "tryCatch" node type - provides structured error handling.
Wraps operations in try/catch/finally blocks for graceful error handling within workflows. Allows workflows to continue execution even when individual operations fail, and enables custom error recovery logic.
Node Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| tryOperations | List | [] | Operations to execute in try block |
| catchOperations | List | [] | Operations to execute on error |
| finallyOperations | List | [] | Operations that always execute |
| errorVariable | String | "error" | Variable name for error info |
| continueOnError | Boolean | true | Continue workflow after error |
| logErrors | Boolean | true | Log errors to console |
Operation Structure
Each operation in tryOperations, catchOperations, or finallyOperations:
- type - Node type to execute (e.g., "httpRequest")
- name - Display name (optional)
- config - Configuration for that node type
Execution Flow
1. Execute tryOperations in sequence
2. IF error occurs:
- Store error info in [errorVariable]
- Execute catchOperations
3. ALWAYS execute finallyOperations
4. Return combined output or throw if continueOnError=false
Error Information
When an error occurs, the following is stored in the error variable:
- message - Error message string
- type - Exception class name
- timestamp - When error occurred
- operation - Which operation failed
Output Data
| Key | Type | Description |
|---|---|---|
| success | Boolean | True if try block completed without errors |
| hasError | Boolean | True if an error was caught |
| [errorVariable] | Map | Error information (if error occurred) |
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTryCatchExecutor(NodeExecutorRegistry nodeExecutorRegistry) Creates a new try-catch executor. -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
Constructor Details
-
TryCatchExecutor
Creates a new try-catch executor.- Parameters:
nodeExecutorRegistry- the registry for accessing other node executors
-
-
Method Details
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-
execute
public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Description copied from interface:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.parameters()to access user settings.input- Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.context- Verification context providing access to workflow-scoped services, logger, and execution metadata.- Returns:
- A Map containing the results of this node's execution.
Keys in this map become available variables for downstream nodes.
Note: Returningnullis treated as an empty map.
-