From 9aa3023da142aa28a2fdcb9fd9a018d57d3b93bf Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Sat, 2 Aug 2025 22:55:02 +0200 Subject: [PATCH] Adding more helpful error messages to the Questionhelper --- src/Symfony/Component/Console/Helper/QuestionHelper.php | 2 +- .../Component/Console/Tests/Helper/QuestionHelperTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index fcbc56fda6b5e..da7db4f1f3134 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -271,7 +271,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu // as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false. if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) { shell_exec('stty '.$sttyMode); - throw new MissingInputException('Aborted.'); + throw new MissingInputException('Aborted while asking: '.$question->getQuestion()); } elseif ("\177" === $c) { // Backspace Character if (0 === $numMatches && 0 !== $i) { --$i; diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index b6ecc5ed3a3ad..555cbe724d6ec 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -750,7 +750,7 @@ public function testAskThrowsExceptionOnMissingInput() public function testAskThrowsExceptionOnMissingInputForChoiceQuestion() { $this->expectException(MissingInputException::class); - $this->expectExceptionMessage('Aborted.'); + $this->expectExceptionMessage('Aborted while asking: Choice'); (new QuestionHelper())->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new ChoiceQuestion('Choice', ['a', 'b'])); }