- Added new exception PackageException in \ncc\Exceptions to replace all package related exceptions

- Removed unused exception `HttpException` in `\ncc\Exceptions` in favor of `NetworkException`
 - Removed unused exception `ComposerDisabledException` in `\ncc\Exceptions` in favor of `ComposerException`
 - Removed unused exception `ComposerNotAvailable` in `\ncc\Exceptions` in favor of `ComposerException`
 - Removed unused exception `InternalComposerNotAvailable` in `\ncc\Exceptions` in favor of `ComposerException`
 - Removed unused exception `PackagePreperationFailedException` in `\ncc\Exceptions` in favor of `PackageException`
 - Removed unused exception `PackageParsingException` in `\ncc\Exceptions` in favor of `PackageException`
 - Removed unused exception `MissingDependencyException` in `\ncc\Exceptions` (not used)
 - Removed unused exception `PackageAlreadyInstalledException` in `\ncc\Exceptions` in favor of `PackageException`
 - Removed unused exception `PackageFetchException` in `\ncc\Exceptions` in favor of `PackageException`
This commit is contained in:
Netkas 2023-08-21 21:35:24 -04:00
parent 623da68d29
commit cdbc87e4bc
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
22 changed files with 195 additions and 477 deletions

View file

@ -16,6 +16,7 @@ features.
`FileNotFoundException` in `\ncc\Exceptions` `FileNotFoundException` in `\ncc\Exceptions`
- Added a new interface class `BytecodeObjectInterface` which will be used to implement object types for compiled assets - Added a new interface class `BytecodeObjectInterface` which will be used to implement object types for compiled assets
- Added new exception `GitException` in `\ncc\Exceptions` to replace all git related exceptions - Added new exception `GitException` in `\ncc\Exceptions` to replace all git related exceptions
- Added new exception `PackageException` in `\ncc\Exceptions` to replace all package related exceptions
### Fixed ### Fixed
- Fixed MITM attack vector in `\ncc\Classes > HttpClient > prepareCurl()` - Fixed MITM attack vector in `\ncc\Classes > HttpClient > prepareCurl()`
@ -148,6 +149,15 @@ features.
- Removed unused exception `UndefinedExecutionPolicyExpection` in `\ncc\Exceptions` in favor of `ConfigurationException` - Removed unused exception `UndefinedExecutionPolicyExpection` in `\ncc\Exceptions` in favor of `ConfigurationException`
- Removed unused exception `InvalidExecutionPolicyName` in `\ncc\Exceptions` (not used) - Removed unused exception `InvalidExecutionPolicyName` in `\ncc\Exceptions` (not used)
- Removed unused exception `AccessDeniedException` in `\ncc\Exceptions` in favor of `AuthenticationException` - Removed unused exception `AccessDeniedException` in `\ncc\Exceptions` in favor of `AuthenticationException`
- Removed unused exception `HttpException` in `\ncc\Exceptions` in favor of `NetworkException`
- Removed unused exception `ComposerDisabledException` in `\ncc\Exceptions` in favor of `ComposerException`
- Removed unused exception `ComposerNotAvailable` in `\ncc\Exceptions` in favor of `ComposerException`
- Removed unused exception `InternalComposerNotAvailable` in `\ncc\Exceptions` in favor of `ComposerException`
- Removed unused exception `PackagePreperationFailedException` in `\ncc\Exceptions` in favor of `PackageException`
- Removed unused exception `PackageParsingException` in `\ncc\Exceptions` in favor of `PackageException`
- Removed unused exception `MissingDependencyException` in `\ncc\Exceptions` (not used)
- Removed unused exception `PackageAlreadyInstalledException` in `\ncc\Exceptions` in favor of `PackageException`
- Removed unused exception `PackageFetchException` in `\ncc\Exceptions` in favor of `PackageException`

View file

@ -15,6 +15,7 @@ ConfigurationException
* PROJECT_CONFIGURATION_NOT_FOUND * PROJECT_CONFIGURATION_NOT_FOUND
* UNDEFINED_EXECUTION_POLICY * UNDEFINED_EXECUTION_POLICY
* INVALID_EXECUTION_POLICY_NAME * INVALID_EXECUTION_POLICY_NAME
* INVALID_PACKAGE
AuthenticationException AuthenticationException
* ACCESS_DENIED * ACCESS_DENIED
@ -27,29 +28,29 @@ ResourceNotFoundException
VERSION_NOT_FOUND VERSION_NOT_FOUND
NO_AVAILABLE_UNITS NO_AVAILABLE_UNITS
PackageException PackageLockException
UNSUPPORTED_PACKAGE
INVALID_PACKAGE
PACKAGE_PREPARATION_FAILED
PACKAGE_PARSING_EXCEPTION
PACKAGE_LOCK_EXCEPTION PACKAGE_LOCK_EXCEPTION
PackageException
* PACKAGE_PREPARATION_FAILED
* PACKAGE_PARSING_EXCEPTION
PACKAGE_ALREADY_INSTALLED PACKAGE_ALREADY_INSTALLED
PACKAGE_FETCH_EXCEPTION PACKAGE_FETCH_EXCEPTION
MISSING_DEPENDENCY - MISSING_DEPENDENCY
IOException IOException
IO_EXCEPTION IO_EXCEPTION
SYMLINK_EXCEPTION SYMLINK_EXCEPTION
NetworkException NetworkException
HTTP_EXCEPTION * HTTP_EXCEPTION
UNSUPPORTED_REMOTE_SOURCE_TYPE
ComposerException ComposerException
COMPOSER_DISABLED_EXCEPTION * COMPOSER_DISABLED_EXCEPTION
INTERNAL_COMPOSER_NOT_AVAILABLE * INTERNAL_COMPOSER_NOT_AVAILABLE
COMPOSER_NOT_AVAILABLE * COMPOSER_NOT_AVAILABLE
COMPOSER_EXCEPTION * COMPOSER_EXCEPTION
GitException GitException
* GIT_CLONE_EXCEPTION * GIT_CLONE_EXCEPTION
@ -69,6 +70,8 @@ NotSupportedException
* UNSUPPORTED_COMPONENT_TYPE * UNSUPPORTED_COMPONENT_TYPE
* NOT_SUPPORTED_EXCEPTION * NOT_SUPPORTED_EXCEPTION
* UNSUPPORTED_PROJECT_TYPE * UNSUPPORTED_PROJECT_TYPE
* UNSUPPORTED_REMOTE_SOURCE_TYPE
* UNSUPPORTED_PACKAGE
RuntimeException RuntimeException
RUNTIME RUNTIME

View file

@ -33,17 +33,14 @@
use ncc\Enums\Scopes; use ncc\Enums\Scopes;
use ncc\CLI\Main; use ncc\CLI\Main;
use ncc\Exceptions\BuildException; use ncc\Exceptions\BuildException;
use ncc\Exceptions\ComposerDisabledException;
use ncc\Exceptions\ComposerException; use ncc\Exceptions\ComposerException;
use ncc\Exceptions\ComposerNotAvailableException;
use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\NotSupportedException; use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PathNotFoundException; use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\InternalComposerNotAvailableException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PackageNotFoundException; use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\RuntimeException; use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UserAbortedOperationException; use ncc\Exceptions\UserAbortedOperationException;
use ncc\Interfaces\ServiceSourceInterface; use ncc\Interfaces\ServiceSourceInterface;
@ -79,16 +76,13 @@
* @param RemotePackageInput $packageInput * @param RemotePackageInput $packageInput
* @return string * @return string
* @throws BuildException * @throws BuildException
* @throws ComposerDisabledException
* @throws ComposerException * @throws ComposerException
* @throws ComposerNotAvailableException
* @throws ConfigurationException * @throws ConfigurationException
* @throws IOException * @throws IOException
* @throws InternalComposerNotAvailableException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NotSupportedException * @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException * @throws PathNotFoundException
* @throws RuntimeException * @throws RuntimeException
* @throws UserAbortedOperationException * @throws UserAbortedOperationException
@ -118,16 +112,13 @@
* @param string $path * @param string $path
* @return string * @return string
* @throws BuildException * @throws BuildException
* @throws ComposerDisabledException
* @throws ComposerException * @throws ComposerException
* @throws ComposerNotAvailableException
* @throws ConfigurationException * @throws ConfigurationException
* @throws IOException * @throws IOException
* @throws InternalComposerNotAvailableException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NotSupportedException * @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException * @throws PathNotFoundException
* @throws UserAbortedOperationException * @throws UserAbortedOperationException
*/ */
@ -196,8 +187,8 @@
* @throws IOException * @throws IOException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NotSupportedException * @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException * @throws PathNotFoundException
*/ */
private static function compilePackages(string $composer_lock_path): array private static function compilePackages(string $composer_lock_path): array
@ -519,11 +510,8 @@
* @param string $package * @param string $package
* @param string|null $version * @param string|null $version
* @return string * @return string
* @throws ComposerDisabledException
* @throws ComposerException * @throws ComposerException
* @throws ComposerNotAvailableException
* @throws IOException * @throws IOException
* @throws InternalComposerNotAvailableException
* @throws PathNotFoundException * @throws PathNotFoundException
* @throws UserAbortedOperationException * @throws UserAbortedOperationException
*/ */
@ -592,9 +580,7 @@
* Attempts to find the composer path to use that is currently configured * Attempts to find the composer path to use that is currently configured
* *
* @return string * @return string
* @throws ComposerDisabledException * @throws ComposerException
* @throws ComposerNotAvailableException
* @throws InternalComposerNotAvailableException
*/ */
private static function getComposerPath(): string private static function getComposerPath(): string
{ {
@ -604,7 +590,7 @@
$internal_composer_enabled = Functions::getConfigurationProperty('composer.enable_internal_composer'); $internal_composer_enabled = Functions::getConfigurationProperty('composer.enable_internal_composer');
if ($composer_enabled !== null && $composer_enabled === false) if ($composer_enabled !== null && $composer_enabled === false)
{ {
throw new ComposerDisabledException('Composer is disabled by the configuration `composer.enabled`'); throw new ComposerException('Composer is disabled by the configuration `composer.enabled`');
} }
$config_property = Functions::getConfigurationProperty('composer.executable_path'); $config_property = Functions::getConfigurationProperty('composer.executable_path');
@ -617,7 +603,7 @@
{ {
if (!file_exists(NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'composer.phar')) if (!file_exists(NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'composer.phar'))
{ {
throw new InternalComposerNotAvailableException(NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'composer.phar'); throw new ComposerException(NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'composer.phar');
} }
Console::outDebug(sprintf('using composer path from NCC_EXEC_LOCATION: %s', NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'composer.phar')); Console::outDebug(sprintf('using composer path from NCC_EXEC_LOCATION: %s', NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'composer.phar'));
@ -637,7 +623,7 @@
} }
} }
throw new ComposerNotAvailableException('No composer executable path is configured'); throw new ComposerException('No composer executable path is configured');
} }
/** /**
@ -683,7 +669,7 @@
* @return ProjectConfiguration * @return ProjectConfiguration
* @throws IOException * @throws IOException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws PackagePreparationFailedException * @throws PackageException
* @throws PathNotFoundException * @throws PathNotFoundException
*/ */
private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration
@ -756,7 +742,7 @@
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new PackagePreparationFailedException('Cannot unset flag \'FOLLOW_SYMLINKS\' in DirectoryScanner, ' . $e->getMessage(), $e); throw new PackageException('Cannot unset flag \'FOLLOW_SYMLINKS\' in DirectoryScanner, ' . $e->getMessage(), $e);
} }
// Include file components that can be compiled // Include file components that can be compiled

View file

@ -27,8 +27,8 @@
use ncc\Classes\HttpClient; use ncc\Classes\HttpClient;
use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\GitException; use ncc\Exceptions\GitException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NetworkException;
use ncc\Exceptions\VersionNotFoundException; use ncc\Exceptions\VersionNotFoundException;
use ncc\Interfaces\RepositorySourceInterface; use ncc\Interfaces\RepositorySourceInterface;
use ncc\Objects\DefinedRemoteSource; use ncc\Objects\DefinedRemoteSource;
@ -50,8 +50,8 @@
* @return RepositoryQueryResults * @return RepositoryQueryResults
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
*/ */
public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
{ {
@ -82,8 +82,8 @@
* @return RepositoryQueryResults * @return RepositoryQueryResults
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
* @throws VersionNotFoundException * @throws VersionNotFoundException
*/ */
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
@ -98,8 +98,8 @@
* @return RepositoryQueryResults * @return RepositoryQueryResults
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
* @throws VersionNotFoundException * @throws VersionNotFoundException
*/ */
public static function getNccPackage(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults public static function getNccPackage(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
@ -116,8 +116,8 @@
* @return array * @return array
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
*/ */
private static function getReleases(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): array private static function getReleases(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): array
{ {
@ -188,8 +188,8 @@
* @return array * @return array
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
*/ */
private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array
{ {
@ -215,8 +215,8 @@
* @return mixed * @return mixed
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
* @throws VersionNotFoundException * @throws VersionNotFoundException
*/ */
private static function processReleases(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry): mixed private static function processReleases(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry): mixed

View file

@ -26,8 +26,8 @@
use ncc\Classes\HttpClient; use ncc\Classes\HttpClient;
use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\GitException; use ncc\Exceptions\GitException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NetworkException;
use ncc\Exceptions\NotSupportedException; use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\ResourceNotFoundException; use ncc\Exceptions\ResourceNotFoundException;
use ncc\Interfaces\RepositorySourceInterface; use ncc\Interfaces\RepositorySourceInterface;
@ -51,8 +51,8 @@
* @return RepositoryQueryResults * @return RepositoryQueryResults
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
*/ */
public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry=null): RepositoryQueryResults public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry=null): RepositoryQueryResults
{ {
@ -93,8 +93,8 @@
* @return RepositoryQueryResults * @return RepositoryQueryResults
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
* @throws ResourceNotFoundException * @throws ResourceNotFoundException
*/ */
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
@ -186,8 +186,8 @@
* @return array * @return array
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitException * @throws GitException
* @throws HttpException
* @throws MalformedJsonException * @throws MalformedJsonException
* @throws NetworkException
*/ */
private static function getReleases(string $owner, string $repository, DefinedRemoteSource $definedRemoteSource, ?Entry $entry): array private static function getReleases(string $owner, string $repository, DefinedRemoteSource $definedRemoteSource, ?Entry $entry): array
{ {

View file

@ -26,7 +26,7 @@ namespace ncc\Classes;
use ncc\Enums\HttpRequestType; use ncc\Enums\HttpRequestType;
use ncc\Enums\LogLevel; use ncc\Enums\LogLevel;
use ncc\CLI\Main; use ncc\CLI\Main;
use ncc\Exceptions\HttpException; use ncc\Exceptions\NetworkException;
use ncc\Objects\HttpRequest; use ncc\Objects\HttpRequest;
use ncc\Objects\HttpResponse; use ncc\Objects\HttpResponse;
use ncc\Objects\HttpResponseCache; use ncc\Objects\HttpResponseCache;
@ -123,7 +123,7 @@ namespace ncc\Classes;
* @param HttpRequest $httpRequest * @param HttpRequest $httpRequest
* @param bool $cache * @param bool $cache
* @return HttpResponse * @return HttpResponse
* @throws HttpException * @throws NetworkException
*/ */
public static function request(HttpRequest $httpRequest, bool $cache=false): HttpResponse public static function request(HttpRequest $httpRequest, bool $cache=false): HttpResponse
{ {
@ -158,7 +158,7 @@ namespace ncc\Classes;
{ {
$error = curl_error($curl); $error = curl_error($curl);
curl_close($curl); curl_close($curl);
throw new HttpException($error); throw new NetworkException($error);
} }
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
@ -193,7 +193,7 @@ namespace ncc\Classes;
* @param HttpRequest $httpRequest * @param HttpRequest $httpRequest
* @param string $path * @param string $path
* @return void * @return void
* @throws HttpException * @throws NetworkException
*/ */
public static function download(HttpRequest $httpRequest, string $path): void public static function download(HttpRequest $httpRequest, string $path): void
{ {
@ -208,7 +208,7 @@ namespace ncc\Classes;
{ {
$error = curl_error($curl); $error = curl_error($curl);
curl_close($curl); curl_close($curl);
throw new HttpException($error); throw new NetworkException($error);
} }
curl_close($curl); curl_close($curl);

View file

@ -35,8 +35,8 @@
use ncc\Exceptions\BuildException; use ncc\Exceptions\BuildException;
use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\PathNotFoundException; use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\VersionNotFoundException; use ncc\Exceptions\VersionNotFoundException;
@ -86,8 +86,8 @@
* *
* @param string $build_configuration * @param string $build_configuration
* @return void * @return void
* @throws PackagePreparationFailedException
* @throws ConfigurationException * @throws ConfigurationException
* @throws PackageException
*/ */
public function prepare(string $build_configuration=BuildConfigurationValues::DEFAULT): void public function prepare(string $build_configuration=BuildConfigurationValues::DEFAULT): void
{ {
@ -98,7 +98,7 @@
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new PackagePreparationFailedException($e->getMessage(), $e); throw new PackageException($e->getMessage(), $e);
} }
// Select the build configuration // Select the build configuration
@ -146,7 +146,7 @@
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new PackagePreparationFailedException('Cannot unset flag \'FOLLOW_SYMLINKS\' in DirectoryScanner, ' . $e->getMessage(), $e); throw new PackageException('Cannot unset flag \'FOLLOW_SYMLINKS\' in DirectoryScanner, ' . $e->getMessage(), $e);
} }
// Include file components that can be compiled // Include file components that can be compiled
@ -190,7 +190,7 @@
Console::outVerbose('No components found'); Console::outVerbose('No components found');
} }
// Clear previous excludes and includes // Clear previously excludes and includes
$DirectoryScanner->setExcludes(); $DirectoryScanner->setExcludes();
$DirectoryScanner->setIncludes(); $DirectoryScanner->setIncludes();
@ -296,11 +296,11 @@
} }
catch (VersionNotFoundException $e) catch (VersionNotFoundException $e)
{ {
throw new PackagePreparationFailedException('Static linking not possible, cannot find version ' . $dependency->Version . ' for dependency ' . $dependency->Name, $e); throw new PackageException('Static linking not possible, cannot find version ' . $dependency->Version . ' for dependency ' . $dependency->Name, $e);
} }
catch (PackageLockException $e) catch (PackageLockException $e)
{ {
throw new PackagePreparationFailedException('Static linking not possible, cannot find package lock for dependency ' . $dependency->Name, $e); throw new PackageException('Static linking not possible, cannot find package lock for dependency ' . $dependency->Name, $e);
} }
break; break;

View file

@ -63,21 +63,11 @@
*/ */
public const INVALID_CONSTANT_NAME = -1719; public const INVALID_CONSTANT_NAME = -1719;
/**
* @see PackagePreparationFailedException
*/
public const PACKAGE_PREPARATION_FAILED = -1720;
/** /**
* @see BuildException * @see BuildException
*/ */
public const BUILD_EXCEPTION = -1727; public const BUILD_EXCEPTION = -1727;
/**
* @see PackageParsingException
*/
public const PACKAGE_PARSING_EXCEPTION = -1728;
/** /**
* @see PackageLockException * @see PackageLockException
*/ */
@ -113,31 +103,11 @@
*/ */
public const NO_AVAILABLE_UNITS = -1742; public const NO_AVAILABLE_UNITS = -1742;
/**
* @see PackageAlreadyInstalledException
*/
public const PACKAGE_ALREADY_INSTALLED = -1744;
/** /**
* @see PackageNotFoundException * @see PackageNotFoundException
*/ */
public const PACKAGE_NOT_FOUND = -1745; public const PACKAGE_NOT_FOUND = -1745;
/**
* @see ComposerDisabledException
*/
public const COMPOSER_DISABLED_EXCEPTION = -1746;
/**
* @see InternalComposerNotAvailableException
*/
public const INTERNAL_COMPOSER_NOT_AVAILABLE = -1747;
/**
* @see ComposerNotAvailableException
*/
public const COMPOSER_NOT_AVAILABLE = -1748;
/** /**
* @see ComposerException * @see ComposerException
*/ */
@ -148,16 +118,6 @@
*/ */
public const USER_ABORTED_OPERATION = -1750; public const USER_ABORTED_OPERATION = -1750;
/**
* @see MissingDependencyException
*/
public const MISSING_DEPENDENCY = -1751;
/**
* @see HttpException
*/
public const HTTP_EXCEPTION = -1752;
/** /**
* @see ImportException * @see ImportException
*/ */
@ -178,11 +138,6 @@
*/ */
public const ARCHIVE_EXCEPTION = -1764; public const ARCHIVE_EXCEPTION = -1764;
/**
* @see PackageFetchException
*/
public const PACKAGE_FETCH_EXCEPTION = -1765;
/** /**
* @see SymlinkException * @see SymlinkException
*/ */
@ -203,6 +158,16 @@
*/ */
public const CONFIGURATION_EXCEPTION = -1772; public const CONFIGURATION_EXCEPTION = -1772;
/**
* @see PackageException
*/
public const PACKAGE_EXCEPTION = -1773;
/**
* @see NetworkException
*/
public const NETWORK_EXCEPTION = -1774;
/** /**
* All the exception codes from NCC * All the exception codes from NCC
*/ */
@ -214,9 +179,7 @@
self::AUTOLOAD_GENERATOR, self::AUTOLOAD_GENERATOR,
self::NO_UNITS_FOUND, self::NO_UNITS_FOUND,
self::INVALID_CONSTANT_NAME, self::INVALID_CONSTANT_NAME,
self::PACKAGE_PREPARATION_FAILED,
self::BUILD_EXCEPTION, self::BUILD_EXCEPTION,
self::PACKAGE_PARSING_EXCEPTION,
self::PACKAGE_LOCK_EXCEPTION, self::PACKAGE_LOCK_EXCEPTION,
self::INSTALLATION_EXCEPTION, self::INSTALLATION_EXCEPTION,
self::COMPONENT_DECODE_EXCEPTION, self::COMPONENT_DECODE_EXCEPTION,
@ -224,22 +187,17 @@
self::VERSION_NOT_FOUND, self::VERSION_NOT_FOUND,
self::RUNNER_EXECUTION_EXCEPTION, self::RUNNER_EXECUTION_EXCEPTION,
self::NO_AVAILABLE_UNITS, self::NO_AVAILABLE_UNITS,
self::PACKAGE_ALREADY_INSTALLED,
self::PACKAGE_NOT_FOUND, self::PACKAGE_NOT_FOUND,
self::COMPOSER_DISABLED_EXCEPTION,
self::INTERNAL_COMPOSER_NOT_AVAILABLE,
self::COMPOSER_NOT_AVAILABLE,
self::COMPOSER_EXCEPTION, self::COMPOSER_EXCEPTION,
self::USER_ABORTED_OPERATION, self::USER_ABORTED_OPERATION,
self::MISSING_DEPENDENCY,
self::HTTP_EXCEPTION,
self::AUTHENTICATION_EXCEPTION, self::AUTHENTICATION_EXCEPTION,
self::NOT_SUPPORTED_EXCEPTION, self::NOT_SUPPORTED_EXCEPTION,
self::ARCHIVE_EXCEPTION, self::ARCHIVE_EXCEPTION,
self::PACKAGE_FETCH_EXCEPTION,
self::SYMLINK_EXCEPTION, self::SYMLINK_EXCEPTION,
self::PATH_NOT_FOUND, self::PATH_NOT_FOUND,
self::GIT_EXCEPTION, self::GIT_EXCEPTION,
self::CONFIGURATION_EXCEPTION self::CONFIGURATION_EXCEPTION,
self::PACKAGE_EXCEPTION,
self::NETWORK_EXCEPTION
]; ];
} }

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class ComposerDisabledException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::COMPOSER_DISABLED_EXCEPTION, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class HttpException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::HTTP_EXCEPTION, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class InternalComposerNotAvailableException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::INTERNAL_COMPOSER_NOT_AVAILABLE, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class MissingDependencyException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::MISSING_DEPENDENCY, $previous);
}
}

View file

@ -0,0 +1,39 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class NetworkException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::NETWORK_EXCEPTION, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackageAlreadyInstalledException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_ALREADY_INSTALLED, $previous);
}
}

View file

@ -0,0 +1,39 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackageException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_EXCEPTION, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackageFetchException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_FETCH_EXCEPTION, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackageParsingException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_PARSING_EXCEPTION, $previous);
}
}

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackagePreparationFailedException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_PREPARATION_FAILED, $previous);
}
}

View file

@ -22,7 +22,6 @@
namespace ncc\Interfaces; namespace ncc\Interfaces;
use ncc\Exceptions\MissingDependencyException;
use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException; use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\VersionNotFoundException; use ncc\Exceptions\VersionNotFoundException;
@ -37,7 +36,6 @@ namespace ncc\Interfaces;
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws VersionNotFoundException * @throws VersionNotFoundException
* @throws PackageLockException * @throws PackageLockException
* @throws MissingDependencyException
*/ */
public static function import(VersionEntry $versionEntry, array $options=[]): bool; public static function import(VersionEntry $versionEntry, array $options=[]): bool;
} }

View file

@ -41,13 +41,10 @@
use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\InstallationException; use ncc\Exceptions\InstallationException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\MissingDependencyException;
use ncc\Exceptions\NotSupportedException; use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PackageAlreadyInstalledException; use ncc\Exceptions\PackageException;
use ncc\Exceptions\PackageFetchException;
use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException; use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PackageParsingException;
use ncc\Exceptions\PathNotFoundException; use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\SymlinkException; use ncc\Exceptions\SymlinkException;
@ -103,18 +100,17 @@
* @param Entry|null $entry * @param Entry|null $entry
* @param array $options * @param array $options
* @return string * @return string
* @throws AuthenticationException
* @throws IOException * @throws IOException
* @throws InstallationException * @throws InstallationException
* @throws MissingDependencyException
* @throws NotSupportedException * @throws NotSupportedException
* @throws PackageAlreadyInstalledException
* @throws PackageLockException * @throws PackageLockException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws PackageParsingException
* @throws PathNotFoundException * @throws PathNotFoundException
* @throws RunnerExecutionException * @throws RunnerExecutionException
* @throws SymlinkException * @throws SymlinkException
* @throws VersionNotFoundException * @throws VersionNotFoundException
* @throws PackageException
*/ */
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
{ {
@ -158,7 +154,7 @@
} }
else else
{ {
throw new PackageAlreadyInstalledException('The package ' . $package->assembly->package . '=' . $package->assembly->version . ' is already installed'); throw new PackageException('The package ' . $package->assembly->package . '=' . $package->assembly->version . ' is already installed');
} }
} }
@ -458,7 +454,7 @@
* @return string * @return string
* @throws InstallationException * @throws InstallationException
* @throws NotSupportedException * @throws NotSupportedException
* @throws PackageFetchException * @throws PackageException
*/ */
public function fetchFromSource(string $source, ?Entry $entry=null): string public function fetchFromSource(string $source, ?Entry $entry=null): string
{ {
@ -466,12 +462,12 @@
if($input->source === null) if($input->source === null)
{ {
throw new PackageFetchException('No source specified'); throw new PackageException('No source specified');
} }
if($input->package === null) if($input->package === null)
{ {
throw new PackageFetchException('No package specified'); throw new PackageException('No package specified');
} }
if($input->version === null) if($input->version === null)
@ -494,7 +490,7 @@
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new PackageFetchException('Cannot fetch package from composer source, ' . $e->getMessage(), $e); throw new PackageException('Cannot fetch package from composer source, ' . $e->getMessage(), $e);
} }
} }
@ -592,7 +588,7 @@
{ {
if($exception === null) if($exception === null)
{ {
$exception = new PackageFetchException($e->getMessage(), $e); $exception = new PackageException($e->getMessage(), $e);
} }
else else
{ {
@ -601,19 +597,19 @@
continue; continue;
} }
$exception = new PackageFetchException($e->getMessage(), $exception); $exception = new PackageException($e->getMessage(), $exception);
} }
} }
} }
else else
{ {
$exception = new PackageFetchException('Cannot fetch package from remote source, no assets found'); $exception = new PackageException('Cannot fetch package from remote source, no assets found');
} }
throw $exception; throw $exception;
} }
throw new PackageFetchException(sprintf('Unknown remote source type %s', $remote_source_type)); throw new PackageException(sprintf('Unknown remote source type %s', $remote_source_type));
} }
/** /**
@ -647,14 +643,13 @@
* @param Entry|null $entry * @param Entry|null $entry
* @param array $options * @param array $options
* @return void * @return void
* @throws AuthenticationException
* @throws IOException * @throws IOException
* @throws InstallationException * @throws InstallationException
* @throws MissingDependencyException
* @throws NotSupportedException * @throws NotSupportedException
* @throws PackageAlreadyInstalledException * @throws PackageException
* @throws PackageLockException * @throws PackageLockException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws PackageParsingException
* @throws PathNotFoundException * @throws PathNotFoundException
* @throws RunnerExecutionException * @throws RunnerExecutionException
* @throws SymlinkException * @throws SymlinkException
@ -887,6 +882,7 @@
* @param string $package * @param string $package
* @param string $version * @param string $version
* @return void * @return void
* @throws AuthenticationException
* @throws IOException * @throws IOException
* @throws PackageLockException * @throws PackageLockException
* @throws PackageNotFoundException * @throws PackageNotFoundException
@ -966,6 +962,7 @@
* *
* @param string $package * @param string $package
* @return void * @return void
* @throws AuthenticationException
* @throws PackageLockException * @throws PackageLockException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws VersionNotFoundException * @throws VersionNotFoundException

View file

@ -1,24 +1,24 @@
<?php <?php
/* /*
* Copyright (c) Nosial 2022-2023, all rights reserved. * Copyright (c) Nosial 2022-2023, all rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without * associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following * Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions: * conditions:
* *
* The above copyright notice and this permission notice shall be included in all copies or substantial portions * The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software. * of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
* *
*/ */
/** @noinspection PhpMissingFieldTypeInspection */ /** @noinspection PhpMissingFieldTypeInspection */
@ -29,7 +29,7 @@
use ncc\Enums\PackageStructureVersions; use ncc\Enums\PackageStructureVersions;
use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageParsingException; use ncc\Exceptions\PackageException;
use ncc\Exceptions\PathNotFoundException; use ncc\Exceptions\PathNotFoundException;
use ncc\Interfaces\BytecodeObjectInterface; use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Objects\Package\Component; use ncc\Objects\Package\Component;
@ -243,7 +243,7 @@
* *
* @param string $path * @param string $path
* @return Package * @return Package
* @throws PackageParsingException * @throws PackageException
* @throws PathNotFoundException * @throws PathNotFoundException
*/ */
public static function load(string $path): Package public static function load(string $path): Package
@ -259,7 +259,7 @@
if(stripos($header, 'NCC_PACKAGE') === 0) if(stripos($header, 'NCC_PACKAGE') === 0)
{ {
throw new PackageParsingException('The package \'' . $path . '\' does not appear to be a valid NCC Package (Missing Header)'); throw new PackageException(sprintf("The package '%s' does not appear to be a valid NCC Package (Missing Header)", $path));
} }
// Extract the package structure version // Extract the package structure version
@ -267,7 +267,7 @@
if(!in_array($package_structure_version, PackageStructureVersions::ALL)) if(!in_array($package_structure_version, PackageStructureVersions::ALL))
{ {
throw new PackageParsingException('The package \'' . $path . '\' has a package structure version of ' . $package_structure_version . ' which is not supported by this version NCC'); throw new PackageException(sprintf("The package '%s' does not appear to be a valid NCC Package (Unsupported Package Structure Version)", $path));
} }
// Extract the package encoding type and package type // Extract the package encoding type and package type
@ -306,7 +306,7 @@
break; break;
default: default:
throw new PackageParsingException('Cannot determine the encoding type for the package \'' . $path . '\' (Got ' . $encoding_type . ')'); throw new PackageException(sprintf("The package '%s' does not appear to be a valid NCC Package (Unsupported Encoding Type)", $path));
} }
// Determine the package type // Determine the package type
@ -328,7 +328,7 @@
break; break;
default: default:
throw new PackageParsingException('Cannot determine the package type for the package \'' . $path . '\' (Got ' . $package_type . ')'); throw new PackageException(sprintf("The package '%s' does not appear to be a valid NCC Package (Unsupported Package Type)", $path));
} }
// Assuming all is good, load the entire fire into memory and parse its contents // Assuming all is good, load the entire fire into memory and parse its contents
@ -338,7 +338,7 @@
} }
catch(Exception $e) catch(Exception $e)
{ {
throw new PackageParsingException('Cannot decode the contents of the package \'' . $path . '\', invalid encoding or the package is corrupted, ' . $e->getMessage(), $e); throw new PackageException(sprintf("The package '%s' does not appear to be a valid NCC Package (Invalid Package Contents)", $path), $e);
} }
$package->magic_bytes = $magic_bytes; $package->magic_bytes = $magic_bytes;

View file

@ -41,9 +41,9 @@
use ncc\Classes\PythonExtension\PythonRunner; use ncc\Classes\PythonExtension\PythonRunner;
use ncc\Exceptions\ArchiveException; use ncc\Exceptions\ArchiveException;
use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NetworkException;
use ncc\Exceptions\PathNotFoundException; use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\RunnerExecutionException;
use ncc\Managers\ConfigurationManager; use ncc\Managers\ConfigurationManager;
@ -352,7 +352,7 @@
* Initializes NCC files * Initializes NCC files
* *
* @return void * @return void
* @noinspection PhpRedundantOptionalArgumentInspection * @throws AuthenticationException
*/ */
public static function initializeFiles(): void public static function initializeFiles(): void
{ {
@ -599,7 +599,7 @@
* @param Entry|null $entry * @param Entry|null $entry
* @return string * @return string
* @throws AuthenticationException * @throws AuthenticationException
* @throws HttpException * @throws NetworkException
*/ */
public static function downloadGitServiceFile(string $url, ?Entry $entry=null): string public static function downloadGitServiceFile(string $url, ?Entry $entry=null): string
{ {