Kdyby / Console

Symfony Console integration for Kdyby components
https://packagist.org/packages/kdyby/console
Other
52 stars 54 forks source link

Errors during console presenter/application startup get silenced #81

Open redwormik opened 5 years ago

redwormik commented 5 years ago

Hi,

the DI extension exits the application on error, silencing default error handler as the console application formats the errors better. (https://github.com/Kdyby/Console/blob/28bc206e6c523315943288519d6052973737713a/src/DI/ConsoleExtension.php#L192, https://github.com/Kdyby/Console/blob/28bc206e6c523315943288519d6052973737713a/src/Application.php#L148).

BUT if creation of console presenter / application fails (for example, when I misconfigured some service that gets used in injectPrimary of Nette\Application\UI\Presenter), the Nette application simply quits, because the console application does not run at all and there is no output at all.

I guess the solution would be to setup the Nette application onError handler in the CliPresenter, directly before it calls $this->console->run, would that be OK? Am I missing the point of setting the onError so early?

I would gladly prepare the PR if this or other solution is approved.