8000 [Serializer] error handling inconsistencies fixed in the serializer decoders by rodrigodiez · Pull Request #9586 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] error handling inconsistencies fixed in the serializer decoders #9586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
Reverted some changes
  • Loading branch information
Rodrigo Díez Villamuera committed Nov 23, 2013
commit 05742368c11ecf66834e20bdc4da65a93b490a6e
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Encoder/JsonDecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function decode($data, $format, array $context = array())
}

if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
$message = JsonEncoder::getErrorMessage($this->lastError);
$message = JsonEncoder::getLastErrorMessage();
throw new UnexpectedValueException($message);
}

Expand Down
10 changes: 6 additions & 4 deletions src/Symfony/Component/Serializer/Encoder/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ public function supportsDecoding($format)
/**
* Resolves json_last_error message
*
* @param $error
*
* @return string
*/
public static function getErrorMessage($error)
public static function getLastErrorMessage()
{
switch ($error) {
if (function_exists('json_last_error_msg')) {
return json_last_error_msg();
}

switch (json_last_error()) {
case JSON_ERROR_DEPTH:
return 'Maximum stack depth exceeded';
break;
Expand Down
0