1
0
Fork 0

Tweak exit code for network errors to be 100, refs #11954

pull/11962/head
Jordi Boggiano 2024-05-02 16:49:44 +02:00
parent acf398281c
commit 762f2a37f5
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 10 additions and 2 deletions

View File

@ -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();

View File

@ -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