RPC errors are reported differently to HTTP errors and weren't previously handled automatically.
The subscriber in this PR throws an exception on error if it's added (not default to avoid breaking BC).
Enabling the subscriber is shown in the docs as such:
<?php
use Graze\GuzzleHttp\JsonRpc\Client;
use Graze\GuzzleHttp\JsonRpc\Exception\RequestException;
use Graze\GuzzleHttp\JsonRpc\Subscriber\ErrorSubscriber;
// Create the client
$client = Client::factory('http://localhost:8000');
// Create a request and attach the error subscriber
$request = $client->request(123, 'method', ['key'=>'value']);
$request->getEmitter()->addSubscriber(new ErrorSubscriber());
// Send the request
try {
$client->send($request);
} catch (RequestException $e) {
die($e->getResponse()->getRpcErrorMessage());
}
RPC errors are reported differently to HTTP errors and weren't previously handled automatically. The subscriber in this PR throws an exception on error if it's added (not default to avoid breaking BC).
Enabling the subscriber is shown in the docs as such: