Skip to content

[4.x] Render the error for an unknown command only once - #32

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-unknown-command-error-once
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-unknown-command-error-once

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Running an unknown command printed two error blocks: doExecute() wrote Command "nope" is not defined. itself, dispatched COMMAND_ERROR and rethrew the CommandNotFoundException, and execute() then rendered the same exception again as The command "nope" does not exist..

This removes the extra block from doExecute(), so the error is reported once, through renderThrowable() (on the error output for a ConsoleOutput), as Symfony's Application does. A side effect: with setCatchThrowables(false) the application no longer prints anything itself for an unknown command and leaves the exception to the caller, like for every other error.

Testing Instructions

ApplicationTest::testHandlingThrowables now asserts that The command "foo" does not exist. appears exactly once in the output and that the is not defined block is gone. It fails on 4.x-dev and passes with this change.

Manually: run an application with new ArrayInput(['command' => 'nope']) and a BufferedOutput — before, both messages are printed; after, only The command "nope" does not exist..

Documentation Changes Required

None. The docs do not describe the unknown-command output.

🤖 Generated with Claude Code

doExecute() printed a "Command "x" is not defined." block and then
rethrew the CommandNotFoundException, which execute() rendered a second
time as "The command "x" does not exist.". Leave the output to the
throwable rendering, as Symfony's Application does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar

Hackwar commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant