From e610cb6e1eebdc8c4af845f75205dfb811b8f89c Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 24 Sep 2024 15:01:55 -0400 Subject: [PATCH] Add produceError method to StandardException --- src/Socialbox/Exceptions/StandardException.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Socialbox/Exceptions/StandardException.php b/src/Socialbox/Exceptions/StandardException.php index 282020b..c163c82 100644 --- a/src/Socialbox/Exceptions/StandardException.php +++ b/src/Socialbox/Exceptions/StandardException.php @@ -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); + } } \ No newline at end of file