Add produceError method to StandardException
This commit is contained in:
parent
8c323c3053
commit
e610cb6e1e
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,8 @@ namespace Socialbox\Exceptions;
|
|||
|
||||
use Exception;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Socialbox\Objects\RpcError;
|
||||
use Socialbox\Objects\RpcRequest;
|
||||
use Throwable;
|
||||
|
||||
class StandardException extends Exception
|
||||
|
@ -24,4 +26,9 @@ class StandardException extends Exception
|
|||
{
|
||||
return StandardError::from($this->code);
|
||||
}
|
||||
|
||||
public function produceError(RpcRequest $request): ?RpcError
|
||||
{
|
||||
return $request->produceError(StandardError::from($this->code), $this->message);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue