8000 added catching of php7 fatal exceptions in application #20110 by bozerkins · Pull Request #20111 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

added catching of php7 fatal exceptions in application #20110 #20111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rethrowing original exception extend of wrapper over Error exception
  • Loading branch information
Bogdans Ozerkins committed Oct 3, 2016
commit 97dc736f9aeeb945f1ad8d5a4617886db1771ff9
16 changes: 6 additions & 10 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function setDispatcher(EventDispatcherInterface $dispatcher)
*
* @return int 0 if everything went fine, or an error code
*
* @throws \Exception When doRun returns Exception or Throwable
* @throws \Exception When doRun returns Exception
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
Expand All @@ -120,28 +120,24 @@ public function run(InputInterface $input = null, OutputInterface $output = null

$this->configureIO($input, $output);

$exception = null;
$exitCode = null;
try {
$exitCode = $this->doRun($input, $output);
} catch (\Exception $e) {
$exception = $e;
} catch (\Throwable $e) {
$exception = new FatalThrowableError($e);
}

if ($exception) {
if ($e) {
if (!$this->catchExceptions) {
throw $exception;
throw $e;
}

if ($output instanceof ConsoleOutputInterface) {
$this->renderException($exception, $output->getErrorOutput());
$this->renderException($e, $output->getErrorOutput());
} else {
$this->renderException($exception, $output);
$this->renderException($e, $output);
}

$exitCode = $exception->getCode();
$exitCode = $e->getCode();
if (is_numeric($exitCode)) {
$exitCode = (int) $exitCode;
if (0 === $exitCode) {
Expand Down
0