diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 7c989098f..7919c29d9 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -12,6 +12,7 @@ namespace Composer\Console; +use Composer\Installer; use Composer\IO\NullIO; use Composer\Util\Filesystem; use Composer\Util\Platform; @@ -441,6 +442,13 @@ class Application extends BaseApplication return max(1, $e->getCode()); } + // override TransportException's code for the purpose of parent::run() using it as process exit code + // as http error codes are all beyond the 255 range of permitted exit codes + if ($e instanceof TransportException) { + $reflProp = new \ReflectionProperty($e, 'code'); + $reflProp->setValue($e, Installer::ERROR_TRANSPORT_EXCEPTION); + } + throw $e; } finally { restore_error_handler(); diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 32a149856..5f07b0e17 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -80,8 +80,8 @@ class Installer // used/declared in SolverProblemsException, carried over here for completeness public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; public const ERROR_AUDIT_FAILED = 5; - // technically exceptions are thrown with various status codes >400, but the process exit code is normalized to 255 - public const ERROR_TRANSPORT_EXCEPTION = 255; + // technically exceptions are thrown with various status codes >400, but the process exit code is normalized to 100 + public const ERROR_TRANSPORT_EXCEPTION = 100; /** * @var IOInterface