[Console] simplified code
This commit is contained in:
parent
a69e7569e3
commit
8805cfdf8d
@ -153,7 +153,17 @@ class Application
|
||||
|
||||
$renderException($e);
|
||||
|
||||
$exitCode = $this->getExitCodeForThrowable($e);
|
||||
$exitCode = $e->getCode();
|
||||
if (is_numeric($exitCode)) {
|
||||
$exitCode = (int) $exitCode;
|
||||
if (0 === $exitCode) {
|
||||
$exitCode = 1;
|
||||
}
|
||||
} else {
|
||||
$exitCode = 1;
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
} finally {
|
||||
// if the exception handler changed, keep it
|
||||
// otherwise, unregister $renderException
|
||||
@ -1212,24 +1222,4 @@ class Application
|
||||
$this->add($command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception|\Throwable $throwable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getExitCodeForThrowable($throwable)
|
||||
{
|
||||
$exitCode = $throwable->getCode();
|
||||
if (is_numeric($exitCode)) {
|
||||
$exitCode = (int) $exitCode;
|
||||
if (0 === $exitCode) {
|
||||
$exitCode = 1;
|
||||
}
|
||||
} else {
|
||||
$exitCode = 1;
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user