1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-02-18 17:58:36 +01:00

[Wilds] Slightly simplify fatal handling during "arc" setup

Summary:
Ref T13098. We currently handle fatals by printing a message and returning an error code, since this was the most direct adaptation from the old `arcanist.php` script.

Instead, throw an exception and then handle it above, since we can reasonably do that in one place now.

Test Plan: Ran `arc`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13098

Differential Revision: https://secure.phabricator.com/D19693
This commit is contained in:
epriestley 2018-09-18 11:07:45 -07:00
parent fe0c293895
commit 9a94aa216b

View file

@ -3,9 +3,14 @@
final class ArcanistRuntime { final class ArcanistRuntime {
public function execute(array $argv) { public function execute(array $argv) {
$err = $this->checkEnvironment();
if ($err) { try {
return $err; $this->checkEnvironment();
} catch (Exception $ex) {
echo "CONFIGURATION ERROR\n\n";
echo $ex->getMessage();
echo "\n\n";
return 1;
} }
PhutilTranslator::getInstance() PhutilTranslator::getInstance()
@ -109,7 +114,8 @@ final class ArcanistRuntime {
'minimum supported version ("%s"). Update PHP to continue.', 'minimum supported version ("%s"). Update PHP to continue.',
$cur_version, $cur_version,
$min_version); $min_version);
return $this->fatalError($message);
throw new Exception($message);
} }
if ($is_windows) { if ($is_windows) {
@ -190,17 +196,9 @@ final class ArcanistRuntime {
$problems[] = "PHP was built with this configure command:\n\n{$config}"; $problems[] = "PHP was built with this configure command:\n\n{$config}";
} }
$problems = implode("\n\n", $problems); $problems = implode("\n\n", $problems);
return $this->fatalError($problems);
throw new Exception($problems);
} }
return 0;
}
private function fatalError($message) {
echo "CONFIGURATION ERROR\n\n";
echo $message;
echo "\n\n";
return 1;
} }
private function loadConfiguration(PhutilArgumentParser $args) { private function loadConfiguration(PhutilArgumentParser $args) {