yii\helpers\BaseJson::handleJsonError PHP Метод

handleJsonError() защищенный статический Метод

Handles BaseJson::encode and BaseJson::decode errors by throwing exceptions with the respective error message.
С версии: 2.0.6
protected static handleJsonError ( integer $lastError )
$lastError integer error code from [json_last_error()](http://php.net/manual/en/function.json-last-error.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 InvalidParamException($availableErrors[$lastError], $lastError);
        }
        throw new InvalidParamException('Unknown JSON encoding/decoding error.');
    }