Skip to content

Commit 6fb6e66

Browse files
committed
feat(1091): allow catch on any task
1 parent 0ceb0e3 commit 6fb6e66

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

dsl-reference.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
285285
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
286286
| timeout | `string`<br>[`timeout`](#timeout) | `no` | The configuration of the task's timeout, if any.<br>*If a `string`, must be the name of a [timeout](#timeout) defined in the [workflow's reusable components](#use).* |
287287
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
288+
| catch | [`catch`](#catch) | `no` | Used to handle errors and define retry policies at the current task's level. |
288289
| metadata | `map` | `no` | Additional information about the task. |
289290

290291
#### Call
@@ -1111,7 +1112,8 @@ do:
11111112

11121113
##### Catch
11131114

1114-
Defines the configuration of a catch clause, which a concept used to catch errors.
1115+
Defines the configuration of a catch clause, which is a concept used to catch errors and to define what should happen when they occur.
1116+
Catch nodes can be used with the [`try`](#try) task to handle errors on a group of tasks or with any [`task`](#task) to handle errors on a single task.
11151117

11161118
###### Properties
11171119

@@ -1124,6 +1126,36 @@ Defines the configuration of a catch clause, which a concept used to catch error
11241126
| retry | `string`<br>[`retryPolicy`](#retry) | `no` | The [`retry policy`](#retry) to use, if any, when catching [`errors`](#error).<br>*If a `string`, must be the name of a [retry policy](#retry) defined in the [workflow's reusable components](#use).* |
11251127
| do | [`map[string, task]`](#task) | `no` | The definition of the task(s) to run when catching an error. |
11261128

1129+
##### Examples
1130+
1131+
```yaml
1132+
document:
1133+
dsl: '1.0.0'
1134+
namespace: test
1135+
name: catch-example
1136+
version: '0.1.0'
1137+
do:
1138+
- invalidHttpCall:
1139+
call: http
1140+
with:
1141+
method: get
1142+
endpoint: https://
1143+
catch:
1144+
errors:
1145+
with:
1146+
type: https://serverlessworkflow.io.io/dsl/errors/types/communication
1147+
status: 503
1148+
as: error
1149+
retry:
1150+
delay:
1151+
seconds: 3
1152+
backoff:
1153+
exponential: {}
1154+
limit:
1155+
attempt:
1156+
count: 5
1157+
```
1158+
11271159
#### Wait
11281160

11291161
Allows workflows to pause or delay their execution for a specified period of time.

dsl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ See the [DSL reference](dsl-reference.md#error) for more details about errors.
483483
484484
#### Retries
485485
486-
Errors are critical for both authors and runtimes as they provide a means to communicate and describe the occurrence of problems. This, in turn, enables the definition of mechanisms to catch and act upon these errors. For instance, some errors caught using a [`try`](dsl-reference.md#try) block may be transient and temporary, such as a `503 Service Unavailable`. In such cases, the DSL provides a mechanism to retry a faulted task, allowing for recovery from temporary issues.
486+
Errors are critical for both authors and runtimes as they provide a means to communicate and describe the occurrence of problems. This, in turn, enables the definition of mechanisms to catch and act upon these errors. For instance, some errors may be transient and temporary, such as a `503 Service Unavailable`. In such cases, the DSL provides a mechanism to retry a [`faulted task`](dsl-reference.md#catch), or a [`group of tasks`](dsl-reference.md#try), allowing for recovery from temporary issues.
487487

488488
*Retrying 5 times when an error with 503 is caught:*
489489
```yaml

0 commit comments

Comments
 (0)