From 292c6ac0429154fd643fc66823e872a83dcc1921 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 24 Sep 2024 15:02:02 -0400 Subject: [PATCH] Add StandardException handling in StandardMethods --- src/Socialbox/Enums/StandardMethods.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Socialbox/Enums/StandardMethods.php b/src/Socialbox/Enums/StandardMethods.php index 456d2b7..7200d9b 100644 --- a/src/Socialbox/Enums/StandardMethods.php +++ b/src/Socialbox/Enums/StandardMethods.php @@ -4,6 +4,7 @@ namespace Socialbox\Enums; use Socialbox\Classes\StandardMethods\CreateSession; use Socialbox\Classes\StandardMethods\Ping; +use Socialbox\Exceptions\StandardException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Objects\ClientRequest; use Socialbox\Objects\RpcRequest; @@ -13,14 +14,18 @@ enum StandardMethods : string case PING = 'ping'; case CREATE_SESSION = 'create_session'; + /** + * @param ClientRequest $request + * @param RpcRequest $rpcRequest + * @return SerializableInterface|null + * @throws StandardException + */ public function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { return match ($this) { self::PING => Ping::execute($request, $rpcRequest), self::CREATE_SESSION => CreateSession::execute($request, $rpcRequest), - - default => $rpcRequest->produceError(StandardError::RPC_METHOD_NOT_FOUND, sprintf('The method %s is not handled by the server', $this->value)), }; } } \ No newline at end of file