#220 - Throw a ProcessFailedException instead of a FatalError on the stop error strategy - #224
Merged
Merged
Conversation
…Exception` (with the original exception as `previous`) instead of a `FatalError`, so that the command exits with a non-zero code when a process fails and `ProcessLauncherTask` detects failed sub-processes. Update documentation, add tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #220.
When a task fails with the
stoperror strategy (the default), the process manager throws aSymfony\Component\ErrorHandler\Error\FatalError. This has three consequences:FatalErroris 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.ProcessLauncherTaskdoes not detect failed sub-processes: it relies on the sub-process exit code, so a sub-process failing instopstrategy is considered successful and the parent process ends with "executed successfully".previous. Its class, code and trace are lost, and acatch (\Exception)aroundProcessManager::execute()does not catch the failure.This PR:
CleverAge\ProcessBundle\Exception\ProcessFailedException(a\RuntimeExceptionimplementingProcessExceptionInterface), thrown instead of theFatalError, with the same message and the original exception asprevious.ProcessLauncherTaskdetects failed sub-processes.01-quick_start.mdautomation section,04-advanced_workflow.md,06-testing.md), add tests.The new regression tests fail on
mainand pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.Requirements
Breaking changes
Minor: the exception thrown on a
stopfailure is now aProcessFailedException(\RuntimeException) instead of aFatalError(\Error). Code catchingFatalErroror\Errorexplicitly must catchProcessFailedExceptioninstead (catch (\Throwable)keeps working). Scripts relying on the (wrong) exit code 0 of a failed process now get 1.symfony/error-handleris no longer used bysrc/but is kept incomposer.json.🤖 Generated with Claude Code