Error implements MessageInterface
A response to a request that indicates an error occurred.
Tags
Table of Contents
Interfaces
- MessageInterface
- Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
Constants
- HEADER_MISMATCH : mixed = -32020
- Values in the HTTP headers contradict the request body, or a required header is missing or malformed. Answered with `400 Bad Request`.
- INTERNAL_ERROR : mixed = -32603
- INVALID_PARAMS : mixed = -32602
- INVALID_REQUEST : mixed = -32600
- METHOD_NOT_FOUND : mixed = -32601
- MISSING_REQUIRED_CLIENT_CAPABILITY : mixed = -32021
- Handling the request needs a client capability the client never declared.
- PARSE_ERROR : mixed = -32700
- RESOURCE_NOT_FOUND : mixed = -32002
- SERVER_ERROR : mixed = -32000
- UNSUPPORTED_PROTOCOL_VERSION : mixed = -32022
- The request's protocol version is unknown to this server, or is a version it has chosen not to implement. Answered with `400 Bad Request`.
Properties
Methods
- __construct() : mixed
- forHeaderMismatch() : self
- forInternalError() : self
- forInvalidParams() : self
- forInvalidRequest() : self
- forMethodNotFound() : self
- forMissingRequiredClientCapability() : self
- forParseError() : self
- forResourceNotFound() : self
- forServerError() : self
- forUnsupportedProtocolVersion() : self
- The client is expected to pick a mutually supported version out of $supported and retry, so the list travels with the error rather than only in the message.
- fromArray() : self
- getId() : string|int|null
- jsonSerialize() : array{jsonrpc: string, id?: string|int, error: array{code: int, message: string, data?: mixed}}
Constants
HEADER_MISMATCH
Values in the HTTP headers contradict the request body, or a required header is missing or malformed. Answered with `400 Bad Request`.
public
mixed
HEADER_MISMATCH
= -32020
INTERNAL_ERROR
public
mixed
INTERNAL_ERROR
= -32603
INVALID_PARAMS
public
mixed
INVALID_PARAMS
= -32602
INVALID_REQUEST
public
mixed
INVALID_REQUEST
= -32600
METHOD_NOT_FOUND
public
mixed
METHOD_NOT_FOUND
= -32601
MISSING_REQUIRED_CLIENT_CAPABILITY
Handling the request needs a client capability the client never declared.
public
mixed
MISSING_REQUIRED_CLIENT_CAPABILITY
= -32021
Answered with 400 Bad Request.
PARSE_ERROR
public
mixed
PARSE_ERROR
= -32700
RESOURCE_NOT_FOUND
public
mixed
RESOURCE_NOT_FOUND
= -32002
SERVER_ERROR
public
mixed
SERVER_ERROR
= -32000
UNSUPPORTED_PROTOCOL_VERSION
The request's protocol version is unknown to this server, or is a version it has chosen not to implement. Answered with `400 Bad Request`.
public
mixed
UNSUPPORTED_PROTOCOL_VERSION
= -32022
Properties
$code read-only
public
int
$code
$data read-only
public
mixed
$data
= null
$id read-only
public
string|int|null
$id
$message read-only
public
string
$message
Methods
__construct()
public
__construct(string|int|null $id, int $code, string $message[, mixed|null $data = null ]) : mixed
Parameters
- $id : string|int|null
-
The id of the request this answers.
nullonly when it could not be read — a malformed body, or a notification that was refused — in which case the member is omitted rather than sent as an id nobody issued. - $code : int
-
the error type that occurred
- $message : string
-
a short description of the error
- $data : mixed|null = null
-
additional information about the error
forHeaderMismatch()
public
final static forHeaderMismatch(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforInternalError()
public
final static forInternalError(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforInvalidParams()
public
final static forInvalidParams(string $message[, string|int|null $id = null ][, mixed $data = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
- $data : mixed = null
Return values
selfforInvalidRequest()
public
final static forInvalidRequest(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforMethodNotFound()
public
final static forMethodNotFound(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforMissingRequiredClientCapability()
public
final static forMissingRequiredClientCapability(string $message, ClientCapabilities $requiredCapabilities[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $requiredCapabilities : ClientCapabilities
-
the capabilities the server needs to process the request
- $id : string|int|null = null
Return values
selfforParseError()
public
final static forParseError(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforResourceNotFound()
public
final static forResourceNotFound(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforServerError()
public
final static forServerError(string $message[, string|int|null $id = null ]) : self
Parameters
- $message : string
- $id : string|int|null = null
Return values
selfforUnsupportedProtocolVersion()
The client is expected to pick a mutually supported version out of $supported and retry, so the list travels with the error rather than only in the message.
public
final static forUnsupportedProtocolVersion(string $requested, array<int, ProtocolVersion> $supported[, string|int|null $id = null ]) : self
Parameters
- $requested : string
- $supported : array<int, ProtocolVersion>
-
versions this server does support
- $id : string|int|null = null
Return values
selffromArray()
public
final static fromArray(ErrorData $data) : self
Parameters
- $data : ErrorData
Return values
selfgetId()
public
getId() : string|int|null
Return values
string|int|nulljsonSerialize()
public
jsonSerialize() : array{jsonrpc: string, id?: string|int, error: array{code: int, message: string, data?: mixed}}