diff --git a/src/Socialbox/Abstracts/Method.php b/src/Socialbox/Abstracts/Method.php index 8214bf5..748f076 100644 --- a/src/Socialbox/Abstracts/Method.php +++ b/src/Socialbox/Abstracts/Method.php @@ -2,7 +2,7 @@ namespace Socialbox\Abstracts; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Objects\ClientRequest; use Socialbox\Objects\RpcRequest; @@ -15,7 +15,7 @@ * @param ClientRequest $request The full client request object, used to identify the client & it's requests * @param RpcRequest $rpcRequest The selected RPC request for the method to handle * @return SerializableInterface|null Returns RpcResponse/RpcError on success, null if the request is a notification - * @throws StandardException If a standard exception is thrown, it will be handled by the engine. + * @throws StandardRpcException If a standard exception is thrown, it will be handled by the engine. */ public static abstract function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface; } \ No newline at end of file diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookAddContact.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookAddContact.php index 3bf7671..2f4a88e 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookAddContact.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookAddContact.php @@ -9,7 +9,7 @@ use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\Standard\InvalidRpcArgumentException; use Socialbox\Exceptions\Standard\MissingRpcArgumentException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -76,7 +76,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to add contact', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to add contact', StandardError::INTERNAL_SERVER_ERROR, $e); } // Return success diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php index c12efd0..087baa2 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookContactExists.php @@ -8,7 +8,7 @@ use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\Standard\InvalidRpcArgumentException; use Socialbox\Exceptions\Standard\MissingRpcArgumentException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -45,7 +45,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check if the contact exists', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check if the contact exists', StandardError::INTERNAL_SERVER_ERROR, $e); } } } \ No newline at end of file diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php index 2ab7463..1f27565 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php @@ -8,7 +8,7 @@ use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\Standard\InvalidRpcArgumentException; use Socialbox\Exceptions\Standard\MissingRpcArgumentException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -53,7 +53,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to remove contact', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to remove contact', StandardError::INTERNAL_SERVER_ERROR, $e); } // Return success diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php index 00f61db..201f9f7 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContact.php @@ -6,7 +6,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -31,7 +31,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); } try @@ -45,7 +45,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to get contact', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to get contact', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($contact->toStandard()); diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContacts.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContacts.php index 8033a84..5f9775e 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContacts.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookGetContacts.php @@ -6,7 +6,7 @@ use Socialbox\Classes\Configuration; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -49,7 +49,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to get contacts', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to get contacts', StandardError::INTERNAL_SERVER_ERROR, $e); } diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookTrustSignature.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookTrustSignature.php index ca22925..1c6ce68 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookTrustSignature.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookTrustSignature.php @@ -6,7 +6,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -32,7 +32,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); } if(!$rpcRequest->containsParameter('uuid')) @@ -46,7 +46,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e); } try @@ -63,7 +63,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e); } // Return success diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookUpdateRelationship.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookUpdateRelationship.php index 78bd4b5..e30669a 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookUpdateRelationship.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookUpdateRelationship.php @@ -7,7 +7,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\Types\ContactRelationshipType; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; use Socialbox\Objects\ClientRequest; @@ -32,7 +32,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); } if(!$rpcRequest->containsParameter('relationship')) @@ -42,7 +42,7 @@ $relationship = ContactRelationshipType::tryFrom(strtoupper($rpcRequest->getParameter('relationship'))); if($relationship === null) { - throw new StandardException('Invalid relationship type', StandardError::RPC_INVALID_ARGUMENTS); + throw new StandardRpcException('Invalid relationship type', StandardError::RPC_INVALID_ARGUMENTS); } try @@ -59,7 +59,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e); } // Return success diff --git a/src/Socialbox/Classes/StandardMethods/Core/GetAllowedMethods.php b/src/Socialbox/Classes/StandardMethods/Core/GetAllowedMethods.php index 338dc8b..49ca7c1 100644 --- a/src/Socialbox/Classes/StandardMethods/Core/GetAllowedMethods.php +++ b/src/Socialbox/Classes/StandardMethods/Core/GetAllowedMethods.php @@ -6,7 +6,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\StandardMethods; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Objects\ClientRequest; use Socialbox\Objects\RpcRequest; @@ -31,7 +31,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to retrieve allowed methods due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to retrieve allowed methods due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($allowedMethods); diff --git a/src/Socialbox/Classes/StandardMethods/Core/ResolvePeer.php b/src/Socialbox/Classes/StandardMethods/Core/ResolvePeer.php index f410772..a13e0f8 100644 --- a/src/Socialbox/Classes/StandardMethods/Core/ResolvePeer.php +++ b/src/Socialbox/Classes/StandardMethods/Core/ResolvePeer.php @@ -7,7 +7,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\ReservedUsernames; use Socialbox\Enums\StandardError; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Objects\ClientRequest; use Socialbox\Objects\PeerAddress; @@ -35,7 +35,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); } // Check if host is making the request & the identifier is not empty @@ -52,7 +52,7 @@ } catch(Exception $e) { - throw new StandardException(sprintf('There was an error while trying to resolve the peer %s: %s', $peerAddress, $e->getMessage()), StandardError::RESOLUTION_FAILED, $e); + throw new StandardRpcException(sprintf('There was an error while trying to resolve the peer %s: %s', $peerAddress, $e->getMessage()), StandardError::RESOLUTION_FAILED, $e); } } } \ No newline at end of file diff --git a/src/Socialbox/Classes/StandardMethods/Core/ResolvePeerSignature.php b/src/Socialbox/Classes/StandardMethods/Core/ResolvePeerSignature.php index 59ab939..10b483a 100644 --- a/src/Socialbox/Classes/StandardMethods/Core/ResolvePeerSignature.php +++ b/src/Socialbox/Classes/StandardMethods/Core/ResolvePeerSignature.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Objects\ClientRequest; use Socialbox\Objects\PeerAddress; @@ -39,7 +39,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e); } // Parse the peer address @@ -49,20 +49,20 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); } try { return $rpcRequest->produceResponse(Socialbox::resolvePeerSignature($peerAddress, $uuid->toRfc4122())); } - catch(StandardException $e) + catch(StandardRpcException $e) { throw $e; } catch (Exception $e) { - throw new StandardException('Failed to resolve peer signature', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to resolve peer signature', StandardError::INTERNAL_SERVER_ERROR, $e); } } } \ No newline at end of file diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddInformationField.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddInformationField.php index 8fa6ce0..88145ca 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddInformationField.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddInformationField.php @@ -9,7 +9,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\Types\InformationFieldName; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PeerInformationManager; use Socialbox\Managers\SessionManager; @@ -62,7 +62,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to retrieve current peer information', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to retrieve current peer information', StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -76,7 +76,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to add the information field', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to add the information field', StandardError::INTERNAL_SERVER_ERROR, $e); } // Update the session flow if necessary @@ -130,15 +130,15 @@ catch (DatabaseOperationException $e) { // Something is seriously wrong if we can't roll back the information field - throw new StandardException('Failed to rollback the information field', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to rollback the information field', StandardError::INTERNAL_SERVER_ERROR, $e); } - if($e instanceof StandardException) + if($e instanceof StandardRpcException) { throw $e; } - throw new StandardException('Failed to update the session flow', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to update the session flow', StandardError::INTERNAL_SERVER_ERROR, $e); } diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddSignature.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddSignature.php index cdf184f..796f6a2 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddSignature.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsAddSignature.php @@ -7,7 +7,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Classes\Configuration; use Socialbox\Enums\StandardError; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\SigningKeysManager; use Socialbox\Objects\ClientRequest; @@ -54,7 +54,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to add the signing key', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to add the signing key', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($uuid); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteInformationField.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteInformationField.php index 6fbbb8c..32e095e 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteInformationField.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteInformationField.php @@ -7,7 +7,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\Types\InformationFieldName; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PeerInformationManager; use Socialbox\Objects\ClientRequest; @@ -40,7 +40,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to check if the information field exists', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check if the information field exists', StandardError::INTERNAL_SERVER_ERROR, $e); } switch($fieldName) @@ -111,7 +111,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to delete the information field', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to delete the information field', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse(true); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteOtp.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteOtp.php index 2a8fe02..c6d504c 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteOtp.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteOtp.php @@ -8,7 +8,7 @@ use Socialbox\Classes\Cryptography; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\OneTimePasswordManager; use Socialbox\Managers\PasswordManager; @@ -38,7 +38,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -47,7 +47,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } // Password verification is required to set an OTP if a password is set @@ -72,7 +72,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } } @@ -83,7 +83,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse(true); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeletePassword.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeletePassword.php index cb02dd3..caec050 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeletePassword.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeletePassword.php @@ -8,7 +8,7 @@ use Socialbox\Classes\Cryptography; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\CryptographyException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PasswordManager; use Socialbox\Objects\ClientRequest; @@ -67,7 +67,7 @@ } catch (Exception $e) { - throw new StandardException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } // Success diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php index 856db73..0211037 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php @@ -7,7 +7,7 @@ use ncc\ThirdParty\Symfony\Uid\Uuid; use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\SigningKeysManager; use Socialbox\Objects\ClientRequest; @@ -40,7 +40,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to delete the signing key', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to delete the signing key', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse(true); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationField.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationField.php index 2333d71..61447e9 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationField.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationField.php @@ -6,7 +6,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\Types\InformationFieldName; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PeerInformationManager; use Socialbox\Objects\ClientRequest; @@ -35,7 +35,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e); } if($fieldRecord === null) diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationFields.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationFields.php index a702193..30e609f 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationFields.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetInformationFields.php @@ -5,7 +5,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PeerInformationManager; use Socialbox\Objects\ClientRequest; @@ -24,7 +24,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse(array_map(fn($result) => $result->toInformationFieldState(), $fieldRecords)); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKey.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKey.php index 01ddfd0..d58923b 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKey.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKey.php @@ -5,7 +5,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\SigningKeysManager; use Socialbox\Objects\ClientRequest; @@ -29,7 +29,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e); } if($key === null) diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKeys.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKeys.php index e4b729c..ee4dfb1 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKeys.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsGetSigningKeys.php @@ -5,7 +5,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\SigningKeysManager; use Socialbox\Objects\ClientRequest; @@ -24,7 +24,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e); } if(empty($keys)) diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetOtp.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetOtp.php index 7ecc46c..34e933d 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetOtp.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetOtp.php @@ -8,7 +8,7 @@ use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\OneTimePasswordManager; use Socialbox\Managers\PasswordManager; @@ -34,7 +34,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } if($peer->isEnabled()) @@ -46,7 +46,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } } else @@ -76,7 +76,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } } @@ -90,7 +90,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($totpUri); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetPassword.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetPassword.php index 4a6000d..91c688b 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetPassword.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsSetPassword.php @@ -8,7 +8,7 @@ use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PasswordManager; use Socialbox\Managers\SessionManager; @@ -41,7 +41,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -54,7 +54,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse(true); diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php index 6e14a3c..01dc98d 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationField.php @@ -6,7 +6,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\Types\InformationFieldName; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PeerInformationManager; use Socialbox\Objects\ClientRequest; @@ -53,7 +53,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e); } diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationPrivacy.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationPrivacy.php index ce08b2a..9c8e449 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationPrivacy.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdateInformationPrivacy.php @@ -7,7 +7,7 @@ use Socialbox\Enums\StandardError; use Socialbox\Enums\Types\InformationFieldName; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PeerInformationManager; use Socialbox\Objects\ClientRequest; @@ -55,7 +55,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e); } diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdatePassword.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdatePassword.php index e098769..a644788 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdatePassword.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsUpdatePassword.php @@ -7,7 +7,7 @@ use Socialbox\Classes\Cryptography; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PasswordManager; use Socialbox\Objects\ClientRequest; @@ -49,7 +49,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -61,7 +61,7 @@ } catch (Exception $e) { - throw new StandardException('Failed to verify existing password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to verify existing password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -71,7 +71,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse(true); diff --git a/src/Socialbox/Classes/StandardMethods/Verification/Authenticate.php b/src/Socialbox/Classes/StandardMethods/Verification/Authenticate.php index 15dce3f..2fe5438 100644 --- a/src/Socialbox/Classes/StandardMethods/Verification/Authenticate.php +++ b/src/Socialbox/Classes/StandardMethods/Verification/Authenticate.php @@ -6,7 +6,7 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\SessionManager; use Socialbox\Objects\ClientRequest; @@ -35,7 +35,7 @@ } catch(Exception $e) { - throw new StandardException('An error occurred while authenticating the peer', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('An error occurred while authenticating the peer', StandardError::INTERNAL_SERVER_ERROR, $e); } diff --git a/src/Socialbox/Classes/StandardMethods/Verification/VerificationAnswerImageCaptcha.php b/src/Socialbox/Classes/StandardMethods/Verification/VerificationAnswerImageCaptcha.php index 1c5c922..79af8fd 100644 --- a/src/Socialbox/Classes/StandardMethods/Verification/VerificationAnswerImageCaptcha.php +++ b/src/Socialbox/Classes/StandardMethods/Verification/VerificationAnswerImageCaptcha.php @@ -6,7 +6,7 @@ use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\CaptchaManager; use Socialbox\Managers\SessionManager; @@ -37,7 +37,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException("There was an unexpected error while trying to get the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException("There was an unexpected error while trying to get the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -51,7 +51,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($result); diff --git a/src/Socialbox/Classes/StandardMethods/Verification/VerificationGetImageCaptcha.php b/src/Socialbox/Classes/StandardMethods/Verification/VerificationGetImageCaptcha.php index ddc4459..21066e9 100644 --- a/src/Socialbox/Classes/StandardMethods/Verification/VerificationGetImageCaptcha.php +++ b/src/Socialbox/Classes/StandardMethods/Verification/VerificationGetImageCaptcha.php @@ -7,7 +7,7 @@ use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\CaptchaManager; use Socialbox\Objects\ClientRequest; @@ -53,7 +53,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException("There was an unexpected error while trying create the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException("There was an unexpected error while trying create the captcha", StandardError::INTERNAL_SERVER_ERROR, $e); } // Build the captcha diff --git a/src/Socialbox/Classes/StandardMethods/Verification/VerificationOtpAuthentication.php b/src/Socialbox/Classes/StandardMethods/Verification/VerificationOtpAuthentication.php index b85dc6d..3d5c3c1 100644 --- a/src/Socialbox/Classes/StandardMethods/Verification/VerificationOtpAuthentication.php +++ b/src/Socialbox/Classes/StandardMethods/Verification/VerificationOtpAuthentication.php @@ -8,7 +8,7 @@ use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\CryptographyException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\OneTimePasswordManager; use Socialbox\Managers\SessionManager; @@ -55,7 +55,7 @@ } catch (Exception $e) { - throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($result); diff --git a/src/Socialbox/Classes/StandardMethods/Verification/VerificationPasswordAuthentication.php b/src/Socialbox/Classes/StandardMethods/Verification/VerificationPasswordAuthentication.php index 9b1f321..f2cc87b 100644 --- a/src/Socialbox/Classes/StandardMethods/Verification/VerificationPasswordAuthentication.php +++ b/src/Socialbox/Classes/StandardMethods/Verification/VerificationPasswordAuthentication.php @@ -8,7 +8,7 @@ use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\CryptographyException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\PasswordManager; use Socialbox\Managers\SessionManager; @@ -54,7 +54,7 @@ } catch (Exception $e) { - throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e); } return $rpcRequest->produceResponse($result); diff --git a/src/Socialbox/Enums/StandardMethods.php b/src/Socialbox/Enums/StandardMethods.php index d62221a..ee14a03 100644 --- a/src/Socialbox/Enums/StandardMethods.php +++ b/src/Socialbox/Enums/StandardMethods.php @@ -40,7 +40,7 @@ use Socialbox\Classes\StandardMethods\Verification\VerificationPasswordAuthentication; use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\OneTimePasswordManager; use Socialbox\Managers\PasswordManager; @@ -145,7 +145,7 @@ * @param ClientRequest $request The client request object containing necessary data for execution. * @param RpcRequest $rpcRequest The RPC request object providing additional parameters for execution. * @return SerializableInterface|null The result of the operation as a serializable interface or null if no operation matches. - * @throws StandardException If an error occurs during execution + * @throws StandardRpcException If an error occurs during execution */ public function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { @@ -206,7 +206,7 @@ * @param ClientRequest $clientRequest The client request instance to check access against. * @return void * @throws DatabaseOperationException If an error occurs while checking the database for session information. - * @throws StandardException If the method is not allowed for the given client request. + * @throws StandardRpcException If the method is not allowed for the given client request. */ public function checkAccess(ClientRequest $clientRequest): void { @@ -215,7 +215,7 @@ return; } - throw new StandardException(StandardError::METHOD_NOT_ALLOWED->getMessage(), StandardError::METHOD_NOT_ALLOWED); + throw new StandardRpcException(StandardError::METHOD_NOT_ALLOWED->getMessage(), StandardError::METHOD_NOT_ALLOWED); } /** diff --git a/src/Socialbox/Exceptions/Standard/InvalidRpcArgumentException.php b/src/Socialbox/Exceptions/Standard/InvalidRpcArgumentException.php index fe167a9..45b8673 100644 --- a/src/Socialbox/Exceptions/Standard/InvalidRpcArgumentException.php +++ b/src/Socialbox/Exceptions/Standard/InvalidRpcArgumentException.php @@ -4,7 +4,7 @@ use Socialbox\Enums\StandardError; - class InvalidRpcArgumentException extends StandardException + class InvalidRpcArgumentException extends StandardRpcException { /** * Thrown when a required parameter is missing diff --git a/src/Socialbox/Exceptions/Standard/MissingRpcArgumentException.php b/src/Socialbox/Exceptions/Standard/MissingRpcArgumentException.php index ed8d459..6ac23a0 100644 --- a/src/Socialbox/Exceptions/Standard/MissingRpcArgumentException.php +++ b/src/Socialbox/Exceptions/Standard/MissingRpcArgumentException.php @@ -4,7 +4,7 @@ use Socialbox\Enums\StandardError; - class MissingRpcArgumentException extends StandardException + class MissingRpcArgumentException extends StandardRpcException { /** * Thrown when a required parameter is missing diff --git a/src/Socialbox/Exceptions/Standard/StandardException.php b/src/Socialbox/Exceptions/Standard/StandardRpcException.php similarity index 96% rename from src/Socialbox/Exceptions/Standard/StandardException.php rename to src/Socialbox/Exceptions/Standard/StandardRpcException.php index 8cd7382..9b3a002 100644 --- a/src/Socialbox/Exceptions/Standard/StandardException.php +++ b/src/Socialbox/Exceptions/Standard/StandardRpcException.php @@ -10,7 +10,7 @@ use Socialbox\Objects\RpcRequest; use Throwable; - class StandardException extends Exception + class StandardRpcException extends Exception { /** * Thrown as a standard error, with a message and a code diff --git a/src/Socialbox/Managers/SessionManager.php b/src/Socialbox/Managers/SessionManager.php index 683e266..2b4d49c 100644 --- a/src/Socialbox/Managers/SessionManager.php +++ b/src/Socialbox/Managers/SessionManager.php @@ -15,7 +15,7 @@ use Socialbox\Enums\SessionState; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Objects\Database\PeerRecord; use Socialbox\Objects\Database\SessionRecord; use Socialbox\Objects\KeyPair; @@ -181,7 +181,7 @@ * @param string $uuid The unique identifier of the session. * @return SessionRecord The session record corresponding to the given UUID. * @throws DatabaseOperationException If the session record cannot be found or if there is an error during retrieval. - * @throws StandardException + * @throws StandardRpcException */ public static function getSession(string $uuid): SessionRecord { @@ -196,7 +196,7 @@ if ($data === false) { - throw new StandardException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND); + throw new StandardRpcException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND); } // Convert the timestamp fields to DateTime objects @@ -308,7 +308,7 @@ * * @param string $uuid The UUID of the session to retrieve flags for. * @return SessionFlags[] An array of flags associated with the specified session. - * @throws StandardException If the specified session does not exist. + * @throws StandardRpcException If the specified session does not exist. * @throws DatabaseOperationException If there */ private static function getFlags(string $uuid): array @@ -324,7 +324,7 @@ if ($data === false) { - throw new StandardException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND); + throw new StandardRpcException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND); } return SessionFlags::fromString($data['flags']); @@ -341,7 +341,7 @@ * @param string $uuid The unique identifier of the session to which the flags will be added. * @param array $flags The flags to add to the session. * @return void - * @throws DatabaseOperationException|StandardException If there is an error while updating the session in the database. + * @throws DatabaseOperationException|StandardRpcException If there is an error while updating the session in the database. */ public static function addFlags(string $uuid, array $flags): void { @@ -372,7 +372,7 @@ * @param string $uuid The UUID of the session from which the flags will be removed. * @param SessionFlags[] $flags An array of flags to be removed from the session. * @return void - * @throws DatabaseOperationException|StandardException If there is an error while updating the session in the database. + * @throws DatabaseOperationException|StandardRpcException If there is an error while updating the session in the database. */ public static function removeFlags(string $uuid, array $flags): void { @@ -429,7 +429,7 @@ * @param array $flagsToRemove An array of flags to remove from the session if it is marked as complete. * @return void * @throws DatabaseOperationException If there is an error while updating the session in the database. - * @throws StandardException If the session record cannot be found or if there is an error during retrieval. + * @throws StandardRpcException If the session record cannot be found or if there is an error during retrieval. */ public static function updateFlow(SessionRecord $session, array $flagsToRemove=[]): void { diff --git a/src/Socialbox/Objects/RpcRequest.php b/src/Socialbox/Objects/RpcRequest.php index 4e9f438..1efe1d8 100644 --- a/src/Socialbox/Objects/RpcRequest.php +++ b/src/Socialbox/Objects/RpcRequest.php @@ -6,7 +6,7 @@ use Socialbox\Classes\Logger; use Socialbox\Enums\StandardError; use Socialbox\Enums\StandardMethods; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; class RpcRequest implements SerializableInterface @@ -162,10 +162,10 @@ } /** - * @param StandardException $e + * @param StandardRpcException $e * @return RpcError|null */ - public function handleStandardException(StandardException $e): ?RpcError + public function handleStandardException(StandardRpcException $e): ?RpcError { return $this->produceError($e->getStandardError(), $e->getMessage()); } diff --git a/src/Socialbox/Socialbox.php b/src/Socialbox/Socialbox.php index 6fc2685..1b4d0b3 100644 --- a/src/Socialbox/Socialbox.php +++ b/src/Socialbox/Socialbox.php @@ -26,7 +26,7 @@ use Socialbox\Exceptions\RequestException; use Socialbox\Exceptions\ResolutionException; use Socialbox\Exceptions\RpcException; - use Socialbox\Exceptions\Standard\StandardException; + use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Managers\ContactManager; use Socialbox\Managers\ExternalSessionManager; use Socialbox\Managers\PeerInformationManager; @@ -567,7 +567,7 @@ { $method->checkAccess($clientRequest); } - catch (StandardException $e) + catch (StandardRpcException $e) { $response = $e->produceError($rpcRequest); $results[] = $response->toArray(); @@ -587,7 +587,7 @@ $response = $method->execute($clientRequest, $rpcRequest); Logger::getLogger()->debug(sprintf('%s method executed successfully', $rpcRequest->getMethod())); } - catch(StandardException $e) + catch(StandardRpcException $e) { Logger::getLogger()->error('An error occurred while processing the RPC request', $e); $response = $e->produceError($rpcRequest); @@ -755,7 +755,7 @@ * @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved. * @param string $signatureUuid The UUID of the signature key to be resolved. * @return SigningKey The resolved signing key for the peer. - * @throws StandardException If there was an error while resolving the peer signature key. + * @throws StandardRpcException If there was an error while resolving the peer signature key. */ public static function resolvePeerSignature(PeerAddress|string $peerAddress, string $signatureUuid): SigningKey { @@ -768,14 +768,14 @@ } catch(InvalidArgumentException $e) { - throw new StandardException($e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new StandardRpcException($e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e); } } // Prevent resolutions against any host if($peerAddress->getUsername() == ReservedUsernames::HOST) { - throw new StandardException('Cannot resolve signature for a host peer', StandardError::FORBIDDEN); + throw new StandardRpcException('Cannot resolve signature for a host peer', StandardError::FORBIDDEN); } // If the peer is registered within this server @@ -788,22 +788,22 @@ if($peer === null || !$peer?->isEnabled()) { // Fail if the peer is not found or enabled - throw new StandardException(sprintf('The peer %s does not exist', $peerAddress), StandardError::PEER_NOT_FOUND); + throw new StandardRpcException(sprintf('The peer %s does not exist', $peerAddress), StandardError::PEER_NOT_FOUND); } $signingKey = SigningKeysManager::getSigningKey($peer->getUuid(), $signatureUuid); if($signingKey === null) { - throw new StandardException(sprintf('The requested signing key %s was not found', $signatureUuid), StandardError::NOT_FOUND); + throw new StandardRpcException(sprintf('The requested signing key %s was not found', $signatureUuid), StandardError::NOT_FOUND); } } - catch(StandardException $e) + catch(StandardRpcException $e) { throw $e; } catch(Exception $e) { - throw new StandardException('There was an error while trying to resolve the signature key for the peer locally', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('There was an error while trying to resolve the signature key for the peer locally', StandardError::INTERNAL_SERVER_ERROR, $e); } return $signingKey->toStandard(); @@ -816,7 +816,7 @@ } catch(Exception $e) { - throw new StandardException(sprintf('There was an error while trying to communicate with %s', $peerAddress->getDomain()), StandardError::RESOLUTION_FAILED, $e); + throw new StandardRpcException(sprintf('There was an error while trying to communicate with %s', $peerAddress->getDomain()), StandardError::RESOLUTION_FAILED, $e); } try @@ -826,7 +826,7 @@ catch(RpcException $e) { // Reflect the server error to the client - throw new StandardException($e->getMessage(), StandardError::tryFrom((int)$e->getCode()) ?? StandardError::UNKNOWN, $e); + throw new StandardRpcException($e->getMessage(), StandardError::tryFrom((int)$e->getCode()) ?? StandardError::UNKNOWN, $e); } } @@ -836,7 +836,7 @@ * @param PeerAddress|string $peerAddress The external peer address or string identifier to be resolved. * @param PeerAddress|string|null $identifiedAs Optional. The peer address or string identifier by which the caller is identified * @return Peer The resolved external peer after synchronization. - * @throws StandardException Thrown if there was an error with the resolution process + * @throws StandardRpcException Thrown if there was an error with the resolution process */ public static function resolvePeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer { @@ -870,7 +870,7 @@ * @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved. * @param PeerAddress|string|null $identifiedAs Optional. The peer address or string identifier by which the caller is identified * @return Peer The resolved peer after synchronization. - * @throws StandardException Thrown if there was an error with the resolution process + * @throws StandardRpcException Thrown if there was an error with the resolution process */ private static function resolveExternalPeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer { @@ -891,7 +891,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); } if($existingPeer === null) @@ -904,7 +904,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e); + throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e); } try @@ -913,7 +913,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); } return $peer; @@ -928,7 +928,7 @@ } catch(Exception $e) { - throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e); + throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e); } try @@ -937,7 +937,7 @@ } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); } return $peer; @@ -953,7 +953,7 @@ * @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved. * @param PeerAddress|string|null $identifiedAs Optional. The peer address or string identifier by which the caller is identified * @return Peer The resolved peer after synchronization. - * @throws StandardException Thrown if there was an error with the resolution process + * @throws StandardRpcException Thrown if there was an error with the resolution process */ private static function resolveLocalPeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer { @@ -974,12 +974,12 @@ if($peer === null) { - throw new StandardException('The requested peer was not found', StandardError::PEER_NOT_FOUND); + throw new StandardRpcException('The requested peer was not found', StandardError::PEER_NOT_FOUND); } } catch(DatabaseOperationException $e) { - throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); } try @@ -989,7 +989,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); } // If there's an identifier, we can resolve more information fields if the target peer has added the caller @@ -1002,7 +1002,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to resolve peer because there was an error while trying to retrieve contact information for the peer', StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to resolve peer because there was an error while trying to retrieve contact information for the peer', StandardError::INTERNAL_SERVER_ERROR, $e); } // If it is a contact, what sort of contact? retrieve depending on the contact type @@ -1023,7 +1023,7 @@ } catch (DatabaseOperationException $e) { - throw new StandardException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); + throw new StandardRpcException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e); } } }