- 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`
- 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 `PackageException` in `\ncc\Exceptions` to replace all package related exceptions
### Fixed
- 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 `InvalidExecutionPolicyName` in `\ncc\Exceptions` (not used)
- 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
* UNDEFINED_EXECUTION_POLICY
* INVALID_EXECUTION_POLICY_NAME
* INVALID_PACKAGE
AuthenticationException
* ACCESS_DENIED
@ -27,29 +28,29 @@ ResourceNotFoundException
VERSION_NOT_FOUND
NO_AVAILABLE_UNITS
PackageException
UNSUPPORTED_PACKAGE
INVALID_PACKAGE
PACKAGE_PREPARATION_FAILED
PACKAGE_PARSING_EXCEPTION
PackageLockException
PACKAGE_LOCK_EXCEPTION
PackageException
* PACKAGE_PREPARATION_FAILED
* PACKAGE_PARSING_EXCEPTION
PACKAGE_ALREADY_INSTALLED
PACKAGE_FETCH_EXCEPTION
MISSING_DEPENDENCY
- MISSING_DEPENDENCY
IOException
IO_EXCEPTION
SYMLINK_EXCEPTION
NetworkException
HTTP_EXCEPTION
UNSUPPORTED_REMOTE_SOURCE_TYPE
* HTTP_EXCEPTION
ComposerException
COMPOSER_DISABLED_EXCEPTION
INTERNAL_COMPOSER_NOT_AVAILABLE
COMPOSER_NOT_AVAILABLE
COMPOSER_EXCEPTION
* COMPOSER_DISABLED_EXCEPTION
* INTERNAL_COMPOSER_NOT_AVAILABLE
* COMPOSER_NOT_AVAILABLE
* COMPOSER_EXCEPTION
GitException
* GIT_CLONE_EXCEPTION
@ -69,6 +70,8 @@ NotSupportedException
* UNSUPPORTED_COMPONENT_TYPE
* NOT_SUPPORTED_EXCEPTION
* UNSUPPORTED_PROJECT_TYPE
* UNSUPPORTED_REMOTE_SOURCE_TYPE
* UNSUPPORTED_PACKAGE
RuntimeException
RUNTIME

View file

@ -33,17 +33,14 @@
use ncc\Enums\Scopes;
use ncc\CLI\Main;
use ncc\Exceptions\BuildException;
use ncc\Exceptions\ComposerDisabledException;
use ncc\Exceptions\ComposerException;
use ncc\Exceptions\ComposerNotAvailableException;
use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\InternalComposerNotAvailableException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UserAbortedOperationException;
use ncc\Interfaces\ServiceSourceInterface;
@ -79,16 +76,13 @@
* @param RemotePackageInput $packageInput
* @return string
* @throws BuildException
* @throws ComposerDisabledException
* @throws ComposerException
* @throws ComposerNotAvailableException
* @throws ConfigurationException
* @throws IOException
* @throws InternalComposerNotAvailableException
* @throws MalformedJsonException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
* @throws RuntimeException
* @throws UserAbortedOperationException
@ -118,16 +112,13 @@
* @param string $path
* @return string
* @throws BuildException
* @throws ComposerDisabledException
* @throws ComposerException
* @throws ComposerNotAvailableException
* @throws ConfigurationException
* @throws IOException
* @throws InternalComposerNotAvailableException
* @throws MalformedJsonException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
* @throws UserAbortedOperationException
*/
@ -196,8 +187,8 @@
* @throws IOException
* @throws MalformedJsonException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
*/
private static function compilePackages(string $composer_lock_path): array
@ -519,11 +510,8 @@
* @param string $package
* @param string|null $version
* @return string
* @throws ComposerDisabledException
* @throws ComposerException
* @throws ComposerNotAvailableException
* @throws IOException
* @throws InternalComposerNotAvailableException
* @throws PathNotFoundException
* @throws UserAbortedOperationException
*/
@ -592,9 +580,7 @@
* Attempts to find the composer path to use that is currently configured
*
* @return string
* @throws ComposerDisabledException
* @throws ComposerNotAvailableException
* @throws InternalComposerNotAvailableException
* @throws ComposerException
*/
private static function getComposerPath(): string
{
@ -604,7 +590,7 @@
$internal_composer_enabled = Functions::getConfigurationProperty('composer.enable_internal_composer');
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');
@ -617,7 +603,7 @@
{
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'));
@ -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
* @throws IOException
* @throws MalformedJsonException
* @throws PackagePreparationFailedException
* @throws PackageException
* @throws PathNotFoundException
*/
private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration
@ -756,7 +742,7 @@
}
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

View file

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

View file

@ -26,8 +26,8 @@
use ncc\Classes\HttpClient;
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\GitException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NetworkException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\ResourceNotFoundException;
use ncc\Interfaces\RepositorySourceInterface;
@ -51,8 +51,8 @@
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
* @throws NetworkException
*/
public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry=null): RepositoryQueryResults
{
@ -93,8 +93,8 @@
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
* @throws NetworkException
* @throws ResourceNotFoundException
*/
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
@ -186,8 +186,8 @@
* @return array
* @throws AuthenticationException
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
* @throws NetworkException
*/
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\LogLevel;
use ncc\CLI\Main;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\NetworkException;
use ncc\Objects\HttpRequest;
use ncc\Objects\HttpResponse;
use ncc\Objects\HttpResponseCache;
@ -123,7 +123,7 @@ namespace ncc\Classes;
* @param HttpRequest $httpRequest
* @param bool $cache
* @return HttpResponse
* @throws HttpException
* @throws NetworkException
*/
public static function request(HttpRequest $httpRequest, bool $cache=false): HttpResponse
{
@ -158,7 +158,7 @@ namespace ncc\Classes;
{
$error = curl_error($curl);
curl_close($curl);
throw new HttpException($error);
throw new NetworkException($error);
}
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
@ -193,7 +193,7 @@ namespace ncc\Classes;
* @param HttpRequest $httpRequest
* @param string $path
* @return void
* @throws HttpException
* @throws NetworkException
*/
public static function download(HttpRequest $httpRequest, string $path): void
{
@ -208,7 +208,7 @@ namespace ncc\Classes;
{
$error = curl_error($curl);
curl_close($curl);
throw new HttpException($error);
throw new NetworkException($error);
}
curl_close($curl);

View file

@ -35,8 +35,8 @@
use ncc\Exceptions\BuildException;
use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\VersionNotFoundException;
@ -86,8 +86,8 @@
*
* @param string $build_configuration
* @return void
* @throws PackagePreparationFailedException
* @throws ConfigurationException
* @throws PackageException
*/
public function prepare(string $build_configuration=BuildConfigurationValues::DEFAULT): void
{
@ -98,7 +98,7 @@
}
catch (Exception $e)
{
throw new PackagePreparationFailedException($e->getMessage(), $e);
throw new PackageException($e->getMessage(), $e);
}
// Select the build configuration
@ -146,7 +146,7 @@
}
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
@ -190,7 +190,7 @@
Console::outVerbose('No components found');
}
// Clear previous excludes and includes
// Clear previously excludes and includes
$DirectoryScanner->setExcludes();
$DirectoryScanner->setIncludes();
@ -296,11 +296,11 @@
}
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)
{
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;

View file

@ -63,21 +63,11 @@
*/
public const INVALID_CONSTANT_NAME = -1719;
/**
* @see PackagePreparationFailedException
*/
public const PACKAGE_PREPARATION_FAILED = -1720;
/**
* @see BuildException
*/
public const BUILD_EXCEPTION = -1727;
/**
* @see PackageParsingException
*/
public const PACKAGE_PARSING_EXCEPTION = -1728;
/**
* @see PackageLockException
*/
@ -113,31 +103,11 @@
*/
public const NO_AVAILABLE_UNITS = -1742;
/**
* @see PackageAlreadyInstalledException
*/
public const PACKAGE_ALREADY_INSTALLED = -1744;
/**
* @see PackageNotFoundException
*/
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
*/
@ -148,16 +118,6 @@
*/
public const USER_ABORTED_OPERATION = -1750;
/**
* @see MissingDependencyException
*/
public const MISSING_DEPENDENCY = -1751;
/**
* @see HttpException
*/
public const HTTP_EXCEPTION = -1752;
/**
* @see ImportException
*/
@ -178,11 +138,6 @@
*/
public const ARCHIVE_EXCEPTION = -1764;
/**
* @see PackageFetchException
*/
public const PACKAGE_FETCH_EXCEPTION = -1765;
/**
* @see SymlinkException
*/
@ -203,6 +158,16 @@
*/
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
*/
@ -214,9 +179,7 @@
self::AUTOLOAD_GENERATOR,
self::NO_UNITS_FOUND,
self::INVALID_CONSTANT_NAME,
self::PACKAGE_PREPARATION_FAILED,
self::BUILD_EXCEPTION,
self::PACKAGE_PARSING_EXCEPTION,
self::PACKAGE_LOCK_EXCEPTION,
self::INSTALLATION_EXCEPTION,
self::COMPONENT_DECODE_EXCEPTION,
@ -224,22 +187,17 @@
self::VERSION_NOT_FOUND,
self::RUNNER_EXECUTION_EXCEPTION,
self::NO_AVAILABLE_UNITS,
self::PACKAGE_ALREADY_INSTALLED,
self::PACKAGE_NOT_FOUND,
self::COMPOSER_DISABLED_EXCEPTION,
self::INTERNAL_COMPOSER_NOT_AVAILABLE,
self::COMPOSER_NOT_AVAILABLE,
self::COMPOSER_EXCEPTION,
self::USER_ABORTED_OPERATION,
self::MISSING_DEPENDENCY,
self::HTTP_EXCEPTION,
self::AUTHENTICATION_EXCEPTION,
self::NOT_SUPPORTED_EXCEPTION,
self::ARCHIVE_EXCEPTION,
self::PACKAGE_FETCH_EXCEPTION,
self::SYMLINK_EXCEPTION,
self::PATH_NOT_FOUND,
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;
use ncc\Exceptions\MissingDependencyException;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\VersionNotFoundException;
@ -37,7 +36,6 @@ namespace ncc\Interfaces;
* @throws PackageNotFoundException
* @throws VersionNotFoundException
* @throws PackageLockException
* @throws MissingDependencyException
*/
public static function import(VersionEntry $versionEntry, array $options=[]): bool;
}

View file

@ -41,13 +41,10 @@
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\InstallationException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MissingDependencyException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PackageAlreadyInstalledException;
use ncc\Exceptions\PackageFetchException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PackageParsingException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\SymlinkException;
@ -103,18 +100,17 @@
* @param Entry|null $entry
* @param array $options
* @return string
* @throws AuthenticationException
* @throws IOException
* @throws InstallationException
* @throws MissingDependencyException
* @throws NotSupportedException
* @throws PackageAlreadyInstalledException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws PackageParsingException
* @throws PathNotFoundException
* @throws RunnerExecutionException
* @throws SymlinkException
* @throws VersionNotFoundException
* @throws PackageException
*/
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
{
@ -158,7 +154,7 @@
}
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
* @throws InstallationException
* @throws NotSupportedException
* @throws PackageFetchException
* @throws PackageException
*/
public function fetchFromSource(string $source, ?Entry $entry=null): string
{
@ -466,12 +462,12 @@
if($input->source === null)
{
throw new PackageFetchException('No source specified');
throw new PackageException('No source specified');
}
if($input->package === null)
{
throw new PackageFetchException('No package specified');
throw new PackageException('No package specified');
}
if($input->version === null)
@ -494,7 +490,7 @@
}
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)
{
$exception = new PackageFetchException($e->getMessage(), $e);
$exception = new PackageException($e->getMessage(), $e);
}
else
{
@ -601,19 +597,19 @@
continue;
}
$exception = new PackageFetchException($e->getMessage(), $exception);
$exception = new PackageException($e->getMessage(), $exception);
}
}
}
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 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 array $options
* @return void
* @throws AuthenticationException
* @throws IOException
* @throws InstallationException
* @throws MissingDependencyException
* @throws NotSupportedException
* @throws PackageAlreadyInstalledException
* @throws PackageException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws PackageParsingException
* @throws PathNotFoundException
* @throws RunnerExecutionException
* @throws SymlinkException
@ -887,6 +882,7 @@
* @param string $package
* @param string $version
* @return void
* @throws AuthenticationException
* @throws IOException
* @throws PackageLockException
* @throws PackageNotFoundException
@ -966,6 +962,7 @@
*
* @param string $package
* @return void
* @throws AuthenticationException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws VersionNotFoundException

View file

@ -1,24 +1,24 @@
<?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.
*
*/
/*
* 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.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
@ -29,7 +29,7 @@
use ncc\Enums\PackageStructureVersions;
use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageParsingException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Objects\Package\Component;
@ -243,7 +243,7 @@
*
* @param string $path
* @return Package
* @throws PackageParsingException
* @throws PackageException
* @throws PathNotFoundException
*/
public static function load(string $path): Package
@ -259,7 +259,7 @@
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
@ -267,7 +267,7 @@
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
@ -306,7 +306,7 @@
break;
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
@ -328,7 +328,7 @@
break;
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
@ -338,7 +338,7 @@
}
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;

View file

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