This commit is contained in:
Aether
2025-09-28 17:19:23 +08:00
parent 567e430fe9
commit c266a048f1
3 changed files with 20 additions and 1 deletions

View File

@@ -11,10 +11,18 @@ use Hyperf\Rpc\Contract\ResponseInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\MessageInterface;
use Psr\Log\LoggerInterface;
use Throwable;
class JsonRpcExceptionHandler
{
protected LoggerInterface $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* JSON-RPC 异常处理.
* @throws ContainerExceptionInterface
@@ -25,6 +33,8 @@ class JsonRpcExceptionHandler
$responseContents = $response->getBody()->getContents();
$responseContents = json_decode($responseContents, true);
if (! empty($responseContents['error'])) {
$this->logger->error($responseContents['error']);
$port = null;
$config = ApplicationContext::getContainer()->get(ConfigInterface::class);
$servers = $config->get('server.servers');