1. Go to this page and download the library: Download ufo-tech/rpc-exceptions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ufo-tech / rpc-exceptions example snippets
use Ufo\RpcError\AbstractRpcErrorException;
$code = -32700;
$message = 'Some custom error message from rpc server'; // optional
$rpcException = AbstractRpcErrorException::fromCode($code);
// return instance of RpcJsonParseException::class
use Ufo\RpcError\AbstractRpcErrorException;
$data = [
'code' = -32600,
'message' = 'Some custom error message from rpc server',
];
$rpcException = RpcBadRequestException::fromArray($data);
// return instance of RpcBadRequestException::class
use Ufo\RpcError\AbstractRpcErrorException;
$data = "{\"code\":-32500,\"message\":\"Some custom error message from rpc server\"}";
$rpcException = AbstractRpcErrorException::fromArray($data);
// return instance of RpcRuntimeException::class