MCP PHP SDK

Error implements MessageInterface

A response to a request that indicates an error occurred.

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

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

INTERNAL_ERROR  = -32603
INVALID_PARAMS  = -32602
INVALID_REQUEST  = -32600
METHOD_NOT_FOUND  = -32601
PARSE_ERROR  = -32700
RESOURCE_NOT_FOUND  = -32002
SERVER_ERROR  = -32000

Properties

$code  : int
$data  : mixed
$id  : string|int
$message  : string

Methods

__construct()  : mixed
forInternalError()  : self
forInvalidParams()  : self
forInvalidRequest()  : self
forMethodNotFound()  : self
forParseError()  : self
forResourceNotFound()  : self
forServerError()  : self
fromArray()  : self
getId()  : string|int
jsonSerialize()  : array{jsonrpc: string, id: string|int, error: array{code: int, message: string}, data?: mixed}

Constants

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

PARSE_ERROR

public mixed PARSE_ERROR = -32700

RESOURCE_NOT_FOUND

public mixed RESOURCE_NOT_FOUND = -32002

SERVER_ERROR

public mixed SERVER_ERROR = -32000

Properties

$code read-only

public int $code

$data read-only

public mixed $data = null

$id read-only

public string|int $id

$message read-only

public string $message

Methods

__construct()

public __construct(string|int $id, int $code, string $message[, mixed|null $data = null ]) : mixed
Parameters
$id : string|int
$code : int

the error type that occurred

$message : string

a short description of the error

$data : mixed|null = null

additional information about the error

forInternalError()

public final static forInternalError(string $message[, string|int $id = '' ]) : self
Parameters
$message : string
$id : string|int = ''
Return values
self

forInvalidParams()

public final static forInvalidParams(string $message[, string|int $id = '' ][, mixed $data = null ]) : self
Parameters
$message : string
$id : string|int = ''
$data : mixed = null
Return values
self

forInvalidRequest()

public final static forInvalidRequest(string $message[, string|int $id = '' ]) : self
Parameters
$message : string
$id : string|int = ''
Return values
self

forMethodNotFound()

public final static forMethodNotFound(string $message[, string|int $id = '' ]) : self
Parameters
$message : string
$id : string|int = ''
Return values
self

forParseError()

public final static forParseError(string $message[, string|int $id = '' ]) : self
Parameters
$message : string
$id : string|int = ''
Return values
self

forResourceNotFound()

public final static forResourceNotFound(string $message[, string|int $id = '' ]) : self
Parameters
$message : string
$id : string|int = ''
Return values
self

forServerError()

public final static forServerError(string $message[, string|int $id = '' ]) : self
Parameters
$message : string
$id : string|int = ''
Return values
self

fromArray()

public final static fromArray(ErrorData $data) : self
Parameters
$data : ErrorData
Return values
self

getId()

public getId() : string|int
Return values
string|int

jsonSerialize()

public jsonSerialize() : array{jsonrpc: string, id: string|int, error: array{code: int, message: string}, data?: mixed}
Return values
array{jsonrpc: string, id: string|int, error: array{code: int, message: string}, data?: mixed}

        
On this page

Search results