Skip to content

Commit 6d2a9f4

Browse files
ENGCOM-5621: issue/24043: add better exception handling for cli commands #24044
- Merge Pull Request #24044 from PascalBrouwers/magento2:issue/24043 - Merged commits: 1. 9ffe7eb 2. 2861ca4 3. cd9ff1e
2 parents bdcaeaf + cd9ff1e commit 6d2a9f4

File tree

1 file changed

+7
-1
lines changed
  • lib/internal/Magento/Framework/Console

1 file changed

+7
-1
lines changed

lib/internal/Magento/Framework/Console/Cli.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
102102
*/
103103
public function doRun(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
104104
{
105-
$exitCode = parent::doRun($input, $output);
105+
$exitCode = null;
106+
try {
107+
$exitCode = parent::doRun($input, $output);
108+
} catch (\Exception $e) {
109+
$output->writeln($e->getTraceAsString());
110+
}
106111

107112
if ($this->initException) {
108113
throw $this->initException;
@@ -209,6 +214,7 @@ protected function getVendorCommands($objectManager)
209214
$commands = [];
210215
foreach (CommandLocator::getCommands() as $commandListClass) {
211216
if (class_exists($commandListClass)) {
217+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
212218
$commands = array_merge(
213219
$commands,
214220
$objectManager->create($commandListClass)->getCommands()

0 commit comments

Comments
 (0)