diff --git a/dsl-reference.md b/dsl-reference.md index ee1e9c74..9df97ed5 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -1255,6 +1255,7 @@ Defines the configuration of a catch clause, which a concept used to catch error | exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error. | | retry | `string`
[`retryPolicy`](#retry) | `no` | The [`retry policy`](#retry) to use, if any, when catching [`errors`](#error).
*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. | +| then | [`flowDirective`](#flow-directive) | `no` | The [flow directive](#flow-directive) to execute for the error path after the error has been caught (and after executing any `do` tasks, if set). This determines the next transition for the catch path (overriding the try task’s normal completion flow). | #### Wait diff --git a/examples/try-catch-then-directive.yaml b/examples/try-catch-then-directive.yaml new file mode 100644 index 00000000..e7972bc7 --- /dev/null +++ b/examples/try-catch-then-directive.yaml @@ -0,0 +1,26 @@ +document: + dsl: '1.0.3' + namespace: test + name: try-catch-then-directive + version: '0.1.0' +do: + - trySomething: + try: + - callExternalService: + call: http + with: + method: get + endpoint: https://external-service.example.com/api + catch: + errors: + with: + type: https://serverlessworkflow.io/dsl/errors/types/communication + status: 503 + then: recordFailure + - continueProcessing: + set: + status: ok + then: end + - recordFailure: + set: + status: failed diff --git a/schema/workflow.yaml b/schema/workflow.yaml index a443ed50..8a54681c 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -1054,6 +1054,10 @@ $defs: $ref: '#/$defs/taskList' title: TryTaskCatchDo description: The definition of the task(s) to run when catching an error. + then: + $ref: '#/$defs/flowDirective' + title: TryTaskCatchThen + description: The flow directive to execute for the error path after the error has been caught (and after executing any `do` tasks, if set). When set, this determines the next transition instead of the try task's top-level `then` or the default sequential flow. waitTask: type: object title: WaitTask