You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Reenforce that for NonRetryableErrors, users need to manage the error or the Workflow will fail
* Added code example to catch NonRetryableError
---------
Co-authored-by: Sidhartha Chatterjee <[email protected]>
Co-authored-by: Matt Silverlock <[email protected]>
The Workflow instance itself will fail immediately, no further steps will be invoked, and the Workflow will not be retried.
114
+
115
+
## Catch Workflow errors
116
+
117
+
Any uncaught exceptions that propagate to the top level, or any steps that reach their retry limit, will cause the Workflow to end execution in an `Errored` state.
118
+
119
+
If you want to avoid this, you can catch exceptions emitted by a `step`. This can be useful if you need to trigger clean-up tasks or have conditional logic that triggers additional steps.
120
+
121
+
To allow the Workflow to continue its execution, surround the intended steps that are allowed to fail with a `try-catch` block.
122
+
123
+
124
+
```ts
125
+
...
126
+
await step.do('task', async () => {
127
+
// work to be done
128
+
});
129
+
130
+
try {
131
+
await step.do('non-retryable-task', async () => {
132
+
// work not to be retried
133
+
throw new NonRetryableError('oh no');
134
+
});
135
+
} catch(e as Error) {
136
+
console.log(`Step failed: ${e.message}`);
137
+
await step.do('clean-up-task', async () => {
138
+
// Clean up code here
139
+
});
140
+
}
141
+
142
+
// the Workflow will not fail and will continue its execution
0 commit comments