You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A process failing with the stop error strategy throws a FatalError: exit code 0, original exception lost, failed sub-processes not detected #220
When a task fails with the stop error strategy (the default), the process manager throws a Symfony\Component\ErrorHandler\Error\FatalError. This has three consequences:
The command exits with code 0 when a process fails: FatalError is an \Error, not an \Exception, and the console application does not turn it into a non-zero exit code. A cron job, a CI job or a supervisor cannot detect failures. An unknown process code, which throws an \Exception, exits with code 1.
ProcessLauncherTask does not detect failed sub-processes: it relies on the sub-process exit code, so a sub-process failing in stop strategy is considered successful and the parent process ends with "executed successfully".
The original exception is lost: only its message (and file/line) is copied, it is not attached as previous. Its class, code and trace are lost, and a catch (\Exception) around ProcessManager::execute() does not catch the failure.
$ bin/console cleverage:process:execute arb.stop -v
In TransformerTrait.php line 63:
[Symfony\Component\ErrorHandler\Error\FatalError (-1)]
Process arb.stop has failed during process fail with message: 'Transformation 'date_format' have failed: Given value cannot be parsed into a date'.
$ echo $?
0
$ bin/console cleverage:process:execute arb.launcher
Process 'arb.launcher' executed successfully
Add a dedicated CleverAge\ProcessBundle\Exception\ProcessFailedException (a \RuntimeException implementing ProcessExceptionInterface), thrown instead of the FatalError, with the same message and the original exception as previous.
As a consequence, the command exits with code 1 on failure, and ProcessLauncherTask detects failed sub-processes.
Update the documentation (01-quick_start.md automation section, 04-advanced_workflow.md, 06-testing.md), add tests.
Requirements
Documentation updates
Reference
Cookbooks
Changelog
Unit tests
Breaking changes
Minor: the exception thrown on a stop failure is now a ProcessFailedException (\RuntimeException) instead of a FatalError (\Error). Code catching FatalError or \Error explicitly must catch ProcessFailedException instead (catch (\Throwable) keeps working). Scripts relying on the (wrong) exit code 0 of a failed process now get 1. symfony/error-handler is no longer used by src/ but is kept in composer.json.
Activity
Merge pull request #224 from cleverage/220
test #222 Declare ProcessFailedException (#220) as used by ProcessMan…