Task Error Handling
When a task fails, Infinitic captures the exception and provides several ways to handle it:Catching Exceptions in Workflows
You can catch exceptions from failed tasks directly in your workflow code:Failed Task Events
Infinitic emits CloudEvents when tasks fail, allowing you to monitor and react to failures:taskFailed- Task execution failed with an exceptiontaskTimedOut- Task exceeded its timeout durationtaskCanceled- Task was canceled before completiontaskUnknown- Task reference could not be resolved
Workflow Error Handling
Workflows can also fail, and Infinitic provides similar error handling mechanisms:Method Failure Events
methodFailed- Workflow method failed with an exceptionmethodTimedOut- Workflow method exceeded timeoutmethodCanceled- Workflow method was canceled
Remote Method Errors
When calling child workflows, you can handle specific error types:Error Types
Task Errors
- TaskFailedError - Contains the exception thrown during task execution
- TaskTimedOutError - Task exceeded the configured timeout
- TaskCanceledError - Task was explicitly canceled
Workflow Errors
- ChildMethodFailedError - Child workflow method failed
- ChildMethodTimedOutError - Child workflow method timed out
- ChildMethodCanceledError - Child workflow method was canceled
- ChildMethodUnknownError - Child workflow could not be found
Error Propagation
By default, task failures propagate up to the calling workflow. You can control this behavior:Deferred Status
You can check the status of a deferred task or workflow:Best Practices
Use specific exception handlers
Use specific exception handlers
Catch specific exception types rather than generic exceptions to handle different failure scenarios appropriately.
Implement fallback strategies
Implement fallback strategies
Design your workflows with fallback logic for critical tasks to ensure graceful degradation.
Log errors with context
Log errors with context
Include relevant context (task ID, workflow ID, parameters) when logging errors for debugging.
Monitor error events
Monitor error events
Set up CloudEvents listeners to monitor error events and alert on critical failures.
Related Topics
- Retry Policies - Configure automatic retry behavior
- Timeouts - Set timeout durations for tasks and workflows
- CloudEvents - Monitor error events
- Monitoring - Track system health and failures