From: Roland Häder Date: Sat, 18 Feb 2023 02:53:37 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=47c0d0f84a60079b39712d2a3368d8becc4ed109;p=hub.git Continued: - added exception code EXCEPTION_BAD_METHOD_CALL --- diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index fc7f746ae..a59497b60 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -17,6 +17,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Helper\Helper; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -668,7 +669,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception - throw new BadMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET); + throw new BadMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET, FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Debug message @@ -891,7 +892,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); } elseif ($this->getLastSocketErrorCode() === 0) { // Nothing to clear - throw new BadMethodCallException(sprintf('Socket "%s" has no error reported, but method is called.', $this->getSocketResource())); + throw new BadMethodCallException(sprintf('Socket "%s" has no error reported, but method is called.', $this->getSocketResource()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Clear last error diff --git a/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php index a58f23511..19133f5da 100644 --- a/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php +++ b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php @@ -15,6 +15,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; @@ -285,7 +286,7 @@ class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend i //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-FRONTEND: CALLED!'); if (!$this->isLocalNodeRegistered()) { // Not registered but methoded invoked - throw new BadMethodCallException('Node is not locally registered but method called'); + throw new BadMethodCallException('Node is not locally registered but method called', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Get search criteria diff --git a/application/hub/classes/decoder/package/class_PackageDecoder.php b/application/hub/classes/decoder/package/class_PackageDecoder.php index 681b61cb4..270ce73f4 100644 --- a/application/hub/classes/decoder/package/class_PackageDecoder.php +++ b/application/hub/classes/decoder/package/class_PackageDecoder.php @@ -13,6 +13,7 @@ use Org\Shipsimu\Hub\Handler\Network\RawData\Chunks\HandleableChunks; use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; // Import framework stuff +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Registry\Registerable; // Import SPL stuff @@ -107,7 +108,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: CALLED!'); if (!$this->ifUnhandledRawPackageDataLeft()) { // No unhandled package data pending - throw new BadMethodCallException('No unhandled package data is pending but method called'); + throw new BadMethodCallException('No unhandled package data is pending but method called', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // "Pop" the next raw package content @@ -159,7 +160,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { // Check condition if (!$this->ifDeocedPackagesLeft()) { // No decoded packages left - throw new BadMethodCallException('No decoded packages pending but method called'); + throw new BadMethodCallException('No decoded packages pending but method called', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Get the next entry (assoziative array) diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index f020cfb4f..532819b02 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -11,6 +11,7 @@ use Org\Shipsimu\Hub\Helper\Dht\HelpableDht; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait; use Org\Mxchange\CoreFramework\Traits\State\StateableTrait; @@ -246,7 +247,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DHT: CALLED!'); if (!$this->hasEntriesPendingPublication()) { // Bad invocation - throw new BadMethodCallException('Has no entries pending publication but method was called.'); + throw new BadMethodCallException('Has no entries pending publication but method was called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Is there an instance? diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 539f7104d..9ad80ce95 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -37,6 +37,7 @@ use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Factory\Registry\Socket\SocketRegistryFactory; use Org\Mxchange\CoreFramework\Feature\FrameworkFeature; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -1124,7 +1125,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); if (!$this->isEncodedDataPending()) { // Throw exception - throw new BadMethodCallException('No encoded data is pending but this method was called.'); + throw new BadMethodCallException('No encoded data is pending but this method was called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Pop current data from stack @@ -1233,7 +1234,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); if (!$this->isRawDataPending()) { // Should not be invoked anymore - throw new BadMethodCallException('No incoming decoded data on stack but method was called.'); + throw new BadMethodCallException('No incoming decoded data on stack but method was called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // "Pop" the next entry (the same array again) from the stack @@ -1574,7 +1575,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); if (!$this->isNewMessageArrived()) { // Bad method call - throw new BadMethodCallException('No new message arrived but this method has been called.'); + throw new BadMethodCallException('No new message arrived but this method has been called.', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Get it from the stacker, it is the full array with the decoded message @@ -1627,7 +1628,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); if (!$this->isDecodedPackageXmlPending()) { // Bad method call - throw new BadMethodCallException('No package waiting XML parsing'); + throw new BadMethodCallException('No package waiting XML parsing', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Get it from the stacker, it is the full array with the decoded package (raw XML) diff --git a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php index c46bb9671..ff34d4301 100644 --- a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php +++ b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php @@ -9,6 +9,9 @@ use Org\Shipsimu\Hub\Locator\Node\LocateableNode; use Org\Shipsimu\Hub\Locator\Node\Tools\NodeLocatorUtils; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; +// Import framework-specific stuff +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; + // Import SPL stuff use \BadMethodCallException; @@ -85,7 +88,7 @@ abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('IPV4-PROTOCOL-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString())); if (substr($packageInstance->getRecipientUnl(), 0, strlen($this->getProtocolName())) != $this->getProtocolName()) { // Not matching, throw exception - throw new BadMethodCallException(sprintf('packageInstance->recipientUnl=%s cannot be handled by this protocol handler (%s)', $packageInstance->getRecipientUnl(), $this->getProtocolName())); + throw new BadMethodCallException(sprintf('packageInstance->recipientUnl=%s cannot be handled by this protocol handler (%s)', $packageInstance->getRecipientUnl(), $this->getProtocolName()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Default is from generic validation diff --git a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php index f30062a43..34fa6846f 100644 --- a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php @@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Locator\Node\LocateableNode; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Traits\Handler\HandleableTrait; // Import SPL stuff @@ -90,7 +91,7 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper { //* DEBUG-DIE: */ die(__METHOD__.':socketInstance='.print_r($this->getSocketInstance(), TRUE)); if (!$this->isInitialized()) { // Bad method call - throw new BadMethodCallException(sprintf('BASE-IPV4-CONNECTION-HELPER: protocolName=%s is not yet initialized.', $this->getProtocolName())); + throw new BadMethodCallException(sprintf('BASE-IPV4-CONNECTION-HELPER: protocolName=%s is not yet initialized.', $this->getProtocolName()), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // "Cache" socket resource and timeout config diff --git a/application/hub/classes/locator/class_UniversalNodeLocator.php b/application/hub/classes/locator/class_UniversalNodeLocator.php index d3bef3129..1d4f859b7 100644 --- a/application/hub/classes/locator/class_UniversalNodeLocator.php +++ b/application/hub/classes/locator/class_UniversalNodeLocator.php @@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Locator\Node\Tools\NodeLocatorUtils; use Org\Shipsimu\Hub\Tools\HubTools; // Import framework stuff +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Registry\Registerable; // Import SPL stuff @@ -179,7 +180,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING); } elseif ($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL] == 'invalid') { // Is not valid/method to early used - throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL)); + throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Return it @@ -202,7 +203,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING); } elseif ($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL] == 'invalid') { // Is not valid/method to early used - throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL)); + throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Return it diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index 994fbe4ce..c02d2c6f3 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -17,6 +17,7 @@ use Org\Shipsimu\Hub\Traits\Network\Package\Delivery\DeliverableTrait; // Import framework stuff use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Traits\Handler\HandleableTrait; use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait; @@ -206,7 +207,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); if ($this->isPendingDataEmpty()) { // Should not happen - throw new BadMethodCallException('this->pendingData is empty but method was called..'); + throw new BadMethodCallException('this->pendingData is empty but method was called..', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // No markers set? @@ -287,10 +288,10 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, // Validate conditions if (!$this->ifMultipleMessagesPending()) { // Opps? - throw new BadMethodCallException('No multiple messages are pending but method called'); + throw new BadMethodCallException('No multiple messages are pending but method called', FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } elseif (!$this->isPendingDataEmpty()) { // Pending data is not empty but invoked - throw new BadMethodCallException(sprintf('this->pendingData()=%d still filled but method called', strlen($this->pendingData))); + throw new BadMethodCallException(sprintf('this->pendingData()=%d still filled but method called', strlen($this->pendingData)), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // "Pop" next entry from stack and set it as new pending data