Skip to content

Commit

Permalink
Merge pull request #2163 from gmponos/add_invalid_argument_exception
Browse files Browse the repository at this point in the history
Add invalid argument exception
  • Loading branch information
sagikazarmark committed Dec 21, 2018
2 parents d4141ca + 97b2bc9 commit d9b22f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/Exception/InvalidArgumentException.php
@@ -0,0 +1,5 @@
<?php

namespace GuzzleHttp\Exception;

final class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException {}
8 changes: 4 additions & 4 deletions src/functions.php
Expand Up @@ -294,14 +294,14 @@ function is_host_in_noproxy($host, array $noProxyArray)
* @param int $options Bitmask of JSON decode options.
*
* @return mixed
* @throws \InvalidArgumentException if the JSON cannot be decoded.
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
* @link http://www.php.net/manual/en/function.json-decode.php
*/
function json_decode($json, $assoc = false, $depth = 512, $options = 0)
{
$data = \json_decode($json, $assoc, $depth, $options);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
'json_decode error: ' . json_last_error_msg()
);
}
Expand All @@ -317,14 +317,14 @@ function json_decode($json, $assoc = false, $depth = 512, $options = 0)
* @param int $depth Set the maximum depth. Must be greater than zero.
*
* @return string
* @throws \InvalidArgumentException if the JSON cannot be encoded.
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
* @link http://www.php.net/manual/en/function.json-encode.php
*/
function json_encode($value, $options = 0, $depth = 512)
{
$json = \json_encode($value, $options, $depth);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
'json_encode error: ' . json_last_error_msg()
);
}
Expand Down

0 comments on commit d9b22f4

Please sign in to comment.