1 | <?php |
||
18 | final class MalformedInputException extends BadRequestHttpException implements RestExceptionInterface |
||
19 | { |
||
20 | use RestExceptionTrait; |
||
21 | |||
22 | private $errorTypes = array( |
||
23 | JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', |
||
24 | JSON_ERROR_STATE_MISMATCH => 'Underflow or modes mismatch', |
||
25 | JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', |
||
26 | JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', |
||
27 | JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded' |
||
28 | ); |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | * |
||
33 | * @param string $message Error message |
||
34 | * @param \Exception $prev Previous Exception |
||
35 | */ |
||
36 | 2 | public function __construct($message = "Malformed input", $prev = null) |
|
40 | |||
41 | /** |
||
42 | * Sets the specific json error type to make consistent error reporting (and thus testing) possible |
||
43 | * |
||
44 | * @param int $error Error constant from json_last_error |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | 1 | public function setErrorType($error) |
|
54 | } |
||
55 |