]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 18 Feb 2023 02:53:37 +0000 (03:53 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 18 Feb 2023 02:53:37 +0000 (03:53 +0100)
- added exception code EXCEPTION_BAD_METHOD_CALL

application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php
application/hub/classes/decoder/package/class_PackageDecoder.php
application/hub/classes/dht/class_BaseDht.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php
application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php
application/hub/classes/locator/class_UniversalNodeLocator.php
application/hub/classes/package/assembler/class_PackageAssembler.php

index fc7f746aeb8c7bddce8f93f80b2a666fb95c16d8..a59497b60097be0a23308d491f20ae04b8185be4 100644 (file)
@@ -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
index a58f23511e61e5c022b8f926554c6e72e2c3916d..19133f5dac02e4241c6de0525de983dbe932e191 100644 (file)
@@ -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
index 681b61cb444d2a2646fed0e40f43b6aecc65ab5d..270ce73f43e7b92106b49080fca58e0c549b5802 100644 (file)
@@ -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)
index f020cfb4fbfb6dcf6273a11ba2cd0f91609dff86..532819b02b07ecc2ac679b6818ac527957d403f0 100644 (file)
@@ -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?
index 539f7104d6e8fb379bfdcce01e5901cded7c670c..9ad80ce95a3d2e8d7f1e48f6947fb635f44dce80 100644 (file)
@@ -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)
index c46bb9671ac55a7302fc9c4d7f779a00bdfc3917..ff34d43010a877b3f887a6b2267acc8943bdbf62 100644 (file)
@@ -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
index f30062a4347b11cfa2f5523f0526878fc1ad6aee..34fa6846f6f274590b8aafde5fed9a581f3caf7b 100644 (file)
@@ -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
index d3bef31294fc83b37391f3d3676e949e3fb779aa..1d4f859b7db081fb400c7d88e6fda4748d00f35a 100644 (file)
@@ -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
index 994fbe4ceaa5696ed8656edc7415ac790fddb9e6..c02d2c6f3515b879ed03f1cb8eba33abc048c869 100644 (file)
@@ -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