framework/helpers/BaseJson.php
protected static function handleJsonError($lastError)
    {
        if ($lastError === JSON_ERROR_NONE) {
            return;
        }

        $availableErrors = [];
        foreach (static::$jsonErrorMessages as $const => $message) {
            if (defined($const)) {
                $availableErrors[constant($const)] = $message;
            }
        }

        if (isset($availableErrors[$lastError])) {
            throw new InvalidArgumentException($availableErrors[$lastError], $lastError);
        }

        throw new InvalidArgumentException('Unknown JSON encoding/decoding error.');
    }
protected static function handleJsonError($lastError)
    {
        if ($lastError === JSON_ERROR_NONE) {
            return;
        }

        $availableErrors = [];
        foreach (static::$jsonErrorMessages as $const => $message) {
            if (defined($const)) {
                $availableErrors[constant($const)] = $message;
            }
        }

        if (isset($availableErrors[$lastError])) {
            throw new InvalidArgumentException($availableErrors[$lastError], $lastError);
        }

        throw new InvalidArgumentException('Unknown JSON encoding/decoding error.');
    }
protected static function handleJsonError ( $ lastError ) { if ( $ lastError === JSON_ERROR_NONE ) { return ; } $ availableErrors = [ ] ; foreach ( static :: $ jsonErrorMessages as $ const => $ message ) { if ( defined ( $ const ) ) { $ availableErrors [ constant ( $ const ) ] = $ message ; } } if ( isset ( $ availableErrors [ $ lastError ] ) ) { throw new InvalidArgumentException ( $ availableErrors [ $ lastError ] , $ lastError ) ; } throw new InvalidArgumentException ( 'Unknown JSON encoding/decoding error.' ) ; }
Handles [[encode()]] and [[decode()]] errors by throwing exceptions with the respective error message.

@param int $lastError error code from [json_last_error()](https://secure.php.net/manual/en/function.json-last-error.php).
@throws InvalidArgumentException if there is any encoding/decoding error.
@since 2.0.6
Handles [[ encode () ]] and [[ decode () ]] errors by throwing exceptions with the respective error message .