Skip to content

Commit bdc1cba

Browse files
committed
added code example to catch NonRetryableError
1 parent 028a9be commit bdc1cba

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/content/docs/workflows/build/sleeping-and-retrying.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,22 @@ export class MyWorkflow extends WorkflowEntrypoint<Env, Params> {
112112
113113
The Workflow instance itself will fail immediately, no further steps will be invoked, and the Workflow will not be retried.
114114
115-
Like other Errors, any uncaught exceptions that propagate to the top level will cause the Workflow to end execution in an Errored state. Catch the `NonRetryableError` to continue Workflow execution.
115+
Like other Errors, any uncaught exceptions that propagate to the top level will cause the Workflow to end execution in an Errored state. Catch the `NonRetryableError` to continue Workflow execution:
116+
117+
```ts
118+
...
119+
try {
120+
await step.do('task', async () => {
121+
// work not to be retried
122+
throw new NonRetryableError('oh no');
123+
});
124+
} catch {
125+
console.log('error was thrown');
126+
}
127+
128+
// the Workflow will not fail and can continue its execution
129+
130+
await step.do(next task, async() => {
131+
// more work to be done
132+
});
133+
```

0 commit comments

Comments
 (0)