Add option to display internal exceptions in produceError

This commit is contained in:
netkas 2025-01-14 14:53:29 -05:00
parent edf6677256
commit a4602bab91

View file

@ -3,6 +3,8 @@
namespace Socialbox\Exceptions; namespace Socialbox\Exceptions;
use Exception; use Exception;
use Socialbox\Classes\Configuration;
use Socialbox\Classes\Utilities;
use Socialbox\Enums\StandardError; use Socialbox\Enums\StandardError;
use Socialbox\Objects\RpcError; use Socialbox\Objects\RpcError;
use Socialbox\Objects\RpcRequest; use Socialbox\Objects\RpcRequest;
@ -29,6 +31,11 @@
public function produceError(RpcRequest $request): ?RpcError public function produceError(RpcRequest $request): ?RpcError
{ {
if(Configuration::getSecurityConfiguration()->isDisplayInternalExceptions())
{
return $request->produceError(StandardError::from($this->code), Utilities::throwableToString($this));
}
return $request->produceError(StandardError::from($this->code), $this->message); return $request->produceError(StandardError::from($this->code), $this->message);
} }
} }