8000 [Debug] Set exit status to 255 on error by nicolas-grekas · Pull Request #22424 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Debug] Set exit status to 255 on error #22424

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

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Changes from all commits
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
[Debug] Set exit status to 255 on error
  • Loading branch information
nicolas-grekas committed Apr 13, 2017
commit 67e249dc814042e3d3e2fe0497cf944de599df9b
18 changes: 14 additions & 4 deletions src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ErrorHandler
private static $reservedMemory;
private static $stackedErrors = array();
private static $stackedErrorLevels = array();
private static $exitCode = 0;

/**
* Same init value as thrownErrors.
Expand Down Expand Up @@ -477,6 +478,9 @@ public function handleError($type, $message, $file, $line)
*/
public function handleException($exception, array $error = null)
{
if (null === $error) {
self::$exitCode = 255;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better use constant?

}
if (!$exception instanceof \Exception) {
$exception = new FatalThrowableError($exception);
}
Expand Down Expand Up @@ -562,7 +566,7 @@ public static function handleFatalError(array $error = null)
return;
}

if (null === $error) {
if ($exit = null === $error) {
$error = error_get_last();
}

Expand All @@ -586,15 +590,21 @@ public static function handleFatalError(array $error = null)
} else {
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
}
} elseif (!isset($exception)) {
return;
}

try {
$handler->handleException($exception, $error);
if (isset($exception)) {
self::$exitCode = 255;
$handler->handleException($exception, $error);
}
} catch (FatalErrorException $e) {
// Ignore this re-throw
}

if ($exit && self::$exitCode) {
$exitCode = self::$exitCode;
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
}
}

/**
Expand Down
0