Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 34222d7

Browse filesBrowse files
committed
Dispatch console error event
1 parent 1e6810f commit 34222d7
Copy full SHA for 34222d7

File tree

1 file changed

+16
-9
lines changed
Filter options

1 file changed

+16
-9
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+16-9Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,25 +217,32 @@ public function doRun(InputInterface $input, OutputInterface $output)
217217
// the command name MUST be the first element of the input
218218
$command = $this->find($name);
219219
} catch (\Throwable $e) {
220-
if (null !== $this->dispatcher) {
221-
$event = new ConsoleErrorEvent($input, $output, $e);
222-
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
220+
if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
221+
if (null !== $this->dispatcher) {
222+
$event = new ConsoleErrorEvent($input, $output, $e);
223+
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
223224

224-
if (0 === $event->getExitCode()) {
225-
return 0;
226-
}
225+
if (0 === $event->getExitCode()) {
226+
return 0;
227+
}
227228

228-
$e = $event->getError();
229-
}
229+
$e = $event->getError();
230+
}
230231

231-
if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
232232
throw $e;
233233
}
234234

235235
$alternative = $alternatives[0];
236236
$question = new ConfirmationQuestion(sprintf("<error>Command \"%s\" is not defined.</error>\n\nDo you want to run \"%s\" instead? [y/n] ", $name, $alternative), false);
237237

238238
if (!(new QuestionHelper())->ask($input, $output, $question)) {
239+
if (null !== $this->dispatcher) {
240+
$event = new ConsoleErrorEvent($input, $output, $e);
241+
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
242+
243+
return $event->getExitCode();
244+
}
245+
239246
return 1;
240247
}
241248

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.