ProtocolError
ProtocolError
Base class for errors reported to the client as a JSON-RPC error response.
class ProtocolError extends \Hazaar\ExceptionExtends: Hazaar\Exception
MCP error codes live in the JSON-RPC space and are negative, while Hazaar\Exception treats its code as an HTTP status and normalizes anything outside 100-599 to 500. The two are therefore carried separately: the HTTP status goes to the parent constructor, and the JSON-RPC code is held here.
Properties
rpcCode
the JSON-RPC error code sent in the response body
private readonly int $rpcCodeType: int
data
optional structured payload attached to the JSON-RPC error
private readonly mixed $dataType: mixed
Methods
__construct
public __construct(string $message, int $rpcCode, int $httpStatus = 200, mixed $data): voidParameters
| Parameter | Type | Description |
|---|---|---|
$message | string | human-readable error message |
$rpcCode | int | the JSON-RPC error code sent in the response body |
$httpStatus | int | the HTTP status the response is sent with |
$data | mixed | optional structured payload attached to the JSON-RPC error |
getRPCCode
Returns the JSON-RPC error code for the response body.
public getRPCCode(): intReturns: int
getHTTPStatus
Returns the HTTP status the response should be sent with.
public getHTTPStatus(): intReturns: int
getData
Returns the structured payload to attach to the JSON-RPC error, if any.
public getData(): mixedReturns: mixed
Generated by Hazaar API Doc Generator on Sun, 23 Aug 2026 10:49:44 +0000