Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(1091): allow catch on any task #1092

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |
| 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).* |
| then | [`flowDirective`](#flow-directive) | `no` | The flow directive to execute next.<br>*If not set, defaults to `continue`.* |
| catch | [`catch`](#catch) | `no` | Used to handle errors and define retry policies for the current task. |
| metadata | `map` | `no` | Additional information about the task. |

#### Call
Expand Down Expand Up @@ -1111,7 +1112,8 @@ do:

##### Catch

Defines the configuration of a catch clause, which a concept used to catch errors.
Defines the configuration of a catch clause, which is a concept used to catch errors and to define what should happen when they occur.\
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 that single task.

###### Properties

Expand All @@ -1124,6 +1126,36 @@ Defines the configuration of a catch clause, which a concept used to catch error
| 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).* |
| do | [`map[string, task]`](#task) | `no` | The definition of the task(s) to run when catching an error. |

##### Examples

```yaml
document:
dsl: '1.0.0'
namespace: test
name: catch-example
version: '0.1.0'
do:
- invalidHttpCall:
call: http
with:
method: get
endpoint: https://
catch:
errors:
with:
type: https://serverlessworkflow.io.io/dsl/errors/types/communication
status: 503
as: error
retry:
delay:
seconds: 3
backoff:
exponential: {}
limit:
attempt:
count: 5
```

#### Wait

Allows workflows to pause or delay their execution for a specified period of time.
Expand Down
2 changes: 1 addition & 1 deletion dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ See the [DSL reference](dsl-reference.md#error) for more details about errors.

#### Retries

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.
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#task), or a [`group of tasks`](dsl-reference.md#try), allowing for recovery from temporary issues.

*Retrying 5 times when an error with 503 is caught:*
```yaml
Expand Down
Loading