Skip to content

Commit 1cbaac3

Browse files
committed
[Console] simplified code
1 parent c2050fc commit 1cbaac3

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

Application.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,17 @@ public function run(InputInterface $input = null, OutputInterface $output = null
153153

154154
$renderException($e);
155155

156-
$exitCode = $this->getExitCodeForThrowable($e);
156+
$exitCode = $e->getCode();
157+
if (is_numeric($exitCode)) {
158+
$exitCode = (int) $exitCode;
159+
if (0 === $exitCode) {
160+
$exitCode = 1;
161+
}
162+
} else {
163+
$exitCode = 1;
164+
}
165+
166+
return $exitCode;
157167
} finally {
158168
// if the exception handler changed, keep it
159169
// otherwise, unregister $renderException
@@ -1212,24 +1222,4 @@ private function init()
12121222
$this->add($command);
12131223
}
12141224
}
1215-
1216-
/**
1217-
* @param \Exception|\Throwable $throwable
1218-
*
1219-
* @return int
1220-
*/
1221-
private function getExitCodeForThrowable($throwable)
1222-
{
1223-
$exitCode = $throwable->getCode();
1224-
if (is_numeric($exitCode)) {
1225-
$exitCode = (int) $exitCode;
1226-
if (0 === $exitCode) {
1227-
$exitCode = 1;
1228-
}
1229-
} else {
1230-
$exitCode = 1;
1231-
}
1232-
1233-
return $exitCode;
1234-
}
12351225
}

0 commit comments

Comments
 (0)