Skip to content

Runner: use StatusWriter for caught errors #1062

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

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 27, 2025

Description

Errors should go to STDERR. This was mostly handled in PR #1010.

However, the Runner class contains two catch (DeepExitException $e) blocks which are used to exit "early", both for legitimate requests (--version, -i etc), as well as for error output.

This commit changes how the output is handled in these catch blocks, to differentiate between legitimate requests (exit code 0) and error output, sending legitimate output to STDOUT and sending error output to STDERR.

Includes updating a unit test to reflect the change.

Suggested changelog entry

N/A This change is covered by the changelog entry for #1010.

Related issues/external references

Related to squizlabs/PHP_CodeSniffer#1612

Errors should go to `STDERR`. This was mostly handled in PR 1010.

However, the `Runner` class contains two `catch (DeepExitException $e)` blocks which are used to exit "early", both for legitimate requests (`--version`, `-i` etc), as well as for error output.

This commit changes how the output is handled in these catch blocks, to differentiate between legitimate requests (exit code `0`) and error output, sending legitimate output to `STDOUT` and sending error output to `STDERR`.

Includes updating a unit test to reflect the change.

Related to squizlabs/PHP_CodeSniffer 1612
@jrfnl
Copy link
Member Author

jrfnl commented Apr 29, 2025

Rebased without changes. Merges once the build has passed again.

@jrfnl jrfnl force-pushed the phpcs-4.0/feature/sq1612-1010-send-runner-caught-output-to-stderr-stdout branch from 0db9279 to 4cfbf17 Compare April 29, 2025 13:55
@jrfnl jrfnl merged commit 3aa9c99 into 4.x Apr 29, 2025
54 checks passed
@jrfnl jrfnl deleted the phpcs-4.0/feature/sq1612-1010-send-runner-caught-output-to-stderr-stdout branch April 29, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant