Skip to content

Commit 0c4a37f

Browse files
Merge pull request #484 from cleverage/483
#483 - Documentation: an exception thrown by IterableTaskInterface::next() ignores the error strategy
2 parents b88c006 + 9fd6869 commit 0c4a37f

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Latest
22
------
33

4+
## Changes
5+
* [#483](https://github.com/cleverage/process-bundle/issues/483) Documentation: an exception thrown by `IterableTaskInterface::next()` makes the process fail right away with this exception, the `error_strategy` and the `error_outputs` of the task do not apply.
46
## Fixes
57
* [#477](https://github.com/cleverage/process-bundle/issues/477) "Stop the process on the first invalid item" (`error_strategy: skip` and an error branch ending on a `StopTask`) ends as stopped when the failing task is finalizable (`csv_reader`, `xml_stream_reader`, `stat_counter`...): the error of the skipped item, kept by its state, was taken for a finalization failure and the process ended as failed. Add tests.
68
* [#473](https://github.com/cleverage/process-bundle/issues/473) A task failing with the `stop` error strategy makes the process fail even when its error branch stops the flow (`StopTask`, `ProcessState::stop()`): the failure was swallowed, the process ended as succeeded or stopped (`cleverage_process.end` event, exit code 0) and a parent process went on with a `null` output. Update documentation, add tests.

‎docs/02-task_types.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Each execution produces one output (one item) that is immediately sent to the ne
3737
Then the `next` method is called: while it returns `true`, the task is executed again to produce the next item, until
3838
all data have been processed. This way only one item at a time is in memory.
3939

40+
An exception thrown by `next` is not an error of an item: the `error_strategy` and the `error_outputs` of the task do
41+
not apply, the process fails right away with this exception (not wrapped in a `ProcessFailedException`), whatever the
42+
error strategies of its tasks (the task executing a sub-process applies its own strategy to the failure of the
43+
sub-process), after the finalization of the tasks (see [process execution flow](04-advanced_workflow.md#process-execution-flow)).
44+
With the `skip` strategy, going on would either end the iteration silently or call a failing `next` again forever.
45+
4046
The main condition to use them is to have no interaction between each chunk of data. If it's not the case, you might
4147
have to look for another way to organize your data, in order to find bigger chunks.
4248

‎docs/03-custom_tasks.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ Defining your tasks as Iterable or Blocking is as simple as implementing one of
197197
[task types](02-task_types.md) for the complete lifecycle):
198198
* `CleverAge\ProcessBundle\Model\IterableTaskInterface`: the `next` method should behave almost the same as PHP's
199199
native [next](https://www.php.net/manual/en/function.next.php) function for arrays, except it only returns a boolean:
200-
`true` if there is another item to output (the task is then executed again), `false` when the iteration is over
200+
`true` if there is another item to output (the task is then executed again), `false` when the iteration is over.
201+
Read or compute the item in `execute` rather than in `next` when it may fail: an exception thrown by `next` makes the
202+
process fail right away, the `error_strategy` and the `error_outputs` of the task do not apply (see
203+
[iterable tasks](02-task_types.md#iterable-tasks))
201204
* `CleverAge\ProcessBundle\Model\BlockingTaskInterface`: every `execute` method call should only accumulate data from
202205
the input, and once every previous task is _resolved_ (all their executions and iterations are over), the `proceed`
203206
method should provide an output

0 commit comments

Comments
 (0)