Improved InvalidRpcArgumentException handling

This commit is contained in:
netkas 2025-01-31 13:28:28 -05:00
parent 55137a93f2
commit 0ed6a36d50
11 changed files with 43 additions and 25 deletions

View file

@ -7,6 +7,8 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
@ -23,12 +25,12 @@
// Field parameter is required
if(!$rpcRequest->containsParameter('field'))
{
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The required field parameter is missing');
throw new MissingRpcArgumentException('field');
}
$fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field')));
if($fieldName === null)
{
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The provided field parameter is invalid');
throw new InvalidRpcArgumentException('field');
}
try