1 | <?php |
||
8 | class ErrorResponse extends AbstractResponse |
||
9 | { |
||
10 | /** |
||
11 | * Parse error. |
||
12 | */ |
||
13 | const CODE_PARSE_ERROR = -32700; |
||
14 | |||
15 | /** |
||
16 | * Invalid request. |
||
17 | */ |
||
18 | const CODE_INVALID_REQUEST_ERROR = -32600; |
||
19 | |||
20 | /** |
||
21 | * Method not found. |
||
22 | */ |
||
23 | const CODE_METHOD_NOT_FOUND_ERROR = -32601; |
||
24 | |||
25 | /** |
||
26 | * Invalid params. |
||
27 | */ |
||
28 | const CODE_INVALID_PARAMS_ERROR = -32602; |
||
29 | |||
30 | /** |
||
31 | * Internal application error. |
||
32 | */ |
||
33 | const CODE_APPLICATION_ERROR = -32603; |
||
34 | |||
35 | /** |
||
36 | * @var Error |
||
37 | */ |
||
38 | private $error; |
||
39 | |||
40 | /** |
||
41 | * @param string $message |
||
42 | * |
||
43 | * @return ErrorResponse |
||
44 | */ |
||
45 | public static function parseError($message = 'Parse error') |
||
49 | |||
50 | /** |
||
51 | * @param string $message |
||
52 | * |
||
53 | * @return ErrorResponse |
||
54 | */ |
||
55 | public static function invalidRequestError($message = 'Invalid request') |
||
59 | |||
60 | /** |
||
61 | * @param string $id |
||
62 | * @param string $message |
||
63 | * |
||
64 | * @return ErrorResponse |
||
65 | */ |
||
66 | public static function invalidParamsError($id, $message = 'Invalid params') |
||
70 | |||
71 | /** |
||
72 | * @param string $id |
||
73 | * @param string $message |
||
74 | * |
||
75 | * @return ErrorResponse |
||
76 | */ |
||
77 | public static function methodNotFoundError($id, $message = 'Method not found') |
||
81 | |||
82 | /** |
||
83 | * @param string $id |
||
84 | * @param string $message |
||
85 | * |
||
86 | * @return ErrorResponse |
||
87 | */ |
||
88 | public static function applicationError($id, $message = 'Internal error') |
||
92 | |||
93 | /** |
||
94 | * @param string $id |
||
95 | * @param string $message |
||
96 | * @param int $code |
||
97 | * |
||
98 | * @return ErrorResponse |
||
99 | */ |
||
100 | public static function applicationDefinedError($id, $message, $code) |
||
104 | |||
105 | /** |
||
106 | * Constructor. |
||
107 | * |
||
108 | * @param mixed $id |
||
109 | * @param Error $error |
||
110 | */ |
||
111 | public function __construct($id, Error $error) |
||
117 | |||
118 | /** |
||
119 | * @return Error |
||
120 | */ |
||
121 | public function getError() |
||
125 | |||
126 | /** |
||
127 | * @return array |
||
128 | */ |
||
129 | public function toArray() |
||
135 | } |
||
136 |