Introduced common exception superclass

This commit is contained in:
lukas committed 2026-10-15 13:39:44 +00:00
1 parent f749d4a05e
commit afafb1ac3d
12 files changed
+48 -28

No files matched your search

+7 -7
View File
@@ -6,7 +6,7 @@
namespace CloudObjects\SDK\Helpers;
use Exception;
use CloudObjects\SDK\Exceptions\SDKException;
use CloudObjects\SDK\Exceptions\InvalidSDKConfigurationException;
use CloudObjects\SDK\NodeReader, CloudObjects\SDK\ObjectRetriever;
@@ -35,7 +35,7 @@ class SDKLoader {
* @param string $sdkName The name of the SDK to initialize.
* @param array $options Additional options for the SDK (if necessary).
* @return mixed The return value of the SDK initialization, which may vary depending on the SDK.
* @throws Exception If the SDK is not supported or cannot be initialized.
* @throws SDKException If the SDK is not supported or cannot be initialized.
*/
public function init(string $sdkName, array $options = []) : mixed {
$namespace = $this->objectRetriever->getAuthenticatingNamespaceCloudObject();
@@ -52,22 +52,22 @@ class SDKLoader {
], $options));
default:
throw new Exception("No rules defined to initialize SDK with name <".$sdkName.">.");
throw new SDKException("No rules defined to initialize SDK with name <".$sdkName.">.");
}
}
/**
* Initialize and return the SDK with the given classname.
* Throws Exception if the SDK is not supported.
* Throws SDKException if the SDK is not supported.
*
* @param string $classname Classname for the SDK's main class.
* @param array $options Additional options for the SDK (if necessary).
* @return mixed The initialized SDK instance.
* @throws Exception If the SDK is not supported or cannot be initialized.
* @throws SDKException If the SDK is not supported or cannot be initialized.
*/
public function get(string $classname, array $options) : mixed {
if (!class_exists($classname))
throw new Exception("<".$classname."> is not a valid classname.");
throw new SDKException("<".$classname."> is not a valid classname.");
$hashkey = md5($classname.serialize($options));
if (!isset($this->classes[$hashkey])) {
@@ -110,7 +110,7 @@ class SDKLoader {
}
if (!isset($class))
throw new Exception("No rules defined to initialize <".$classname.">.");
throw new SDKException("No rules defined to initialize <".$classname.">.");
$this->classes[$hashkey] = $class;
return $this->classes[$hashkey];