Refactor exception handler to v3, use standard shell exitcode

This commit is contained in:
crazywhalecc
2026-02-15 21:58:42 +08:00
committed by Jerry Ma
parent ee5aabbe34
commit bbab685247
17 changed files with 400 additions and 211 deletions

View File

@@ -29,7 +29,7 @@ class EnvCommand extends BaseCommand
$env = $this->getArgument('env');
if (($val = getenv($env)) === false) {
$this->output->writeln("<error>Environment variable '{$env}' is not set.</error>");
return static::FAILURE;
return static::USER_ERROR;
}
if (is_array($val)) {
foreach ($val as $k => $v) {

View File

@@ -29,6 +29,6 @@ class IsInstalledCommand extends BaseCommand
return static::SUCCESS;
}
$this->output->writeln("<error>Package [{$package}] is not installed.</error>");
return static::FAILURE;
return static::USER_ERROR;
}
}

View File

@@ -34,7 +34,7 @@ class LintConfigCommand extends BaseCommand
if ($checkOnly && $hasChanges) {
$this->output->writeln('<error>Some config files need sorting. Run "bin/spc dev:lint-config" to fix them.</error>');
return static::FAILURE;
return static::VALIDATION_ERROR;
}
return static::SUCCESS;
@@ -125,7 +125,7 @@ class LintConfigCommand extends BaseCommand
return false;
}
ksort($data);
foreach ($data as $artifact_name => &$config) {
foreach ($data as &$config) {
uksort($config, $config_type === 'artifact' ? [$this, 'artifactSortKey'] : [$this, 'packageSortKey']);
}
unset($config);

View File

@@ -28,6 +28,6 @@ class ShellCommand extends BaseCommand
return $code;
}
$this->output->writeln('<error>Unsupported OS for shell command.</error>');
return static::FAILURE;
return static::ENVIRONMENT_ERROR;
}
}