Use own exception

This commit is contained in:
crazywhalecc 2025-06-28 16:45:20 +08:00
parent 924da6ae69
commit 604131b31d
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680

View File

@ -7,6 +7,7 @@ namespace SPC\util\toolchain;
use SPC\builder\freebsd\SystemUtil as FreeBSDSystemUtil; use SPC\builder\freebsd\SystemUtil as FreeBSDSystemUtil;
use SPC\builder\linux\SystemUtil as LinuxSystemUtil; use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
use SPC\builder\macos\SystemUtil as MacOSSystemUtil; use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
use SPC\exception\WrongUsageException;
use SPC\util\GlobalEnvManager; use SPC\util\GlobalEnvManager;
class GccNativeToolchain implements ToolchainInterface class GccNativeToolchain implements ToolchainInterface
@ -23,9 +24,9 @@ class GccNativeToolchain implements ToolchainInterface
{ {
// check gcc exists // check gcc exists
match (PHP_OS_FAMILY) { match (PHP_OS_FAMILY) {
'Linux' => LinuxSystemUtil::findCommand('g++') ?? throw new \RuntimeException('g++ not found, please install it or set CC/CXX to a valid path.'), 'Linux' => LinuxSystemUtil::findCommand('g++') ?? throw new WrongUsageException('g++ not found, please install it or set CC/CXX to a valid path.'),
'Darwin' => MacOSSystemUtil::findCommand('g++') ?? throw new \RuntimeException('g++ not found, please install it or set CC/CXX to a valid path.'), 'Darwin' => MacOSSystemUtil::findCommand('g++') ?? throw new WrongUsageException('g++ not found, please install it or set CC/CXX to a valid path.'),
'BSD' => FreeBSDSystemUtil::findCommand('g++') ?? throw new \RuntimeException('g++ not found, please install it or set CC/CXX to a valid path.'), 'BSD' => FreeBSDSystemUtil::findCommand('g++') ?? throw new WrongUsageException('g++ not found, please install it or set CC/CXX to a valid path.'),
default => throw new \RuntimeException('GCC is not supported on ' . PHP_OS_FAMILY . '.'), default => throw new \RuntimeException('GCC is not supported on ' . PHP_OS_FAMILY . '.'),
}; };
} }