yii\elasticsearch\Connection::decodeErrorBody PHP Method

decodeErrorBody() protected method

Try to decode error information if it is valid json, return it if not.
protected decodeErrorBody ( $body ) : mixed
$body
return mixed
    protected function decodeErrorBody($body)
    {
        try {
            $decoded = Json::decode($body);
            if (isset($decoded['error']) && !is_array($decoded['error'])) {
                $decoded['error'] = preg_replace('/\\b\\w+?Exception\\[/', "<span style=\"color: red;\">\\0</span>\n               ", $decoded['error']);
            }
            return $decoded;
        } catch (InvalidParamException $e) {
            return $body;
        }
    }