Implement client session management and refactoring

This commit is contained in:
netkas 2024-12-09 19:01:56 -05:00
parent cad2ea3419
commit 3a10e01bd8
11 changed files with 234 additions and 23 deletions

View file

@ -3,6 +3,7 @@
namespace Socialbox\Exceptions;
use Exception;
use Socialbox\Objects\RpcError;
use Throwable;
class RpcException extends Exception
@ -18,4 +19,16 @@ class RpcException extends Exception
{
parent::__construct($message, $code, $previous);
}
/**
* Creates an RpcException instance from an RpcError.
*
* @param RpcError $error The RPC error object containing details of the error.
* @param Throwable|null $e The previous throwable used for exception chaining.
* @return RpcException The constructed RpcException instance.
*/
public static function fromRpcError(RpcError $error, ?Throwable $e=null): RpcException
{
return new RpcException($error->getError(), $error->getCode()->value, $e);
}
}