1 | <?php |
||
15 | class ClientException extends \Exception implements \JsonSerializable { |
||
16 | protected $context; |
||
17 | |||
18 | /** |
||
19 | * Initialize an instance of the {@link ClientException} class. |
||
20 | * |
||
21 | * The 4xx class of status code is intended for cases in which the client seems to have erred. |
||
22 | * When constructing a client exception you can pass additional information on the {@link $context} parameter |
||
23 | * to aid in rendering. |
||
24 | * |
||
25 | * - Keys beginning with **HTTP_** will be added as headers. |
||
26 | * - **description** will give the exception a longer description. |
||
27 | * |
||
28 | * @param string $message The error message. |
||
29 | * @param int $code The http error code. |
||
30 | * @param array $context An array of context variables that can be used to render a more detailed response. |
||
31 | */ |
||
32 | 23 | public function __construct($message = '', $code = 400, array $context = []) { |
|
36 | |||
37 | /** |
||
38 | * Gets the response headers that were set on the exception. |
||
39 | * |
||
40 | * @return array Returns the headers for this exception. |
||
41 | */ |
||
42 | 23 | public function getHeaders() { |
|
52 | |||
53 | /** |
||
54 | * Gets a longer description for the exception. |
||
55 | * |
||
56 | * @return string Returns the description of the exception or an empty string if there isn't one. |
||
57 | */ |
||
58 | 23 | public function getDescription() { |
|
61 | |||
62 | /** |
||
63 | * Specify data which should be serialized to JSON. |
||
64 | * |
||
65 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
66 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
67 | * which is a value of any type other than a resource. |
||
68 | */ |
||
69 | 23 | public function jsonSerialize() { |
|
79 | } |
||
80 |