code/thirdparty/gapi.php
private function cleanErrorResponse($error) {
    if (strpos($error, '<html') !== false) {
      $error = preg_replace('/<(style|title|script)[^>]*>[^<]*<\/(style|title|script)>/i', '', $error);
      return trim(preg_replace('/\s+/', ' ', strip_tags($error)));
    }
    else
    {
      $json = json_decode($error);
      return isset($json->error->message) ? strval($json->error->message) : $error;
    }
  }
private function cleanErrorResponse($error) {
    if (strpos($error, '<html') !== false) {
      $error = preg_replace('/<(style|title|script)[^>]*>[^<]*<\/(style|title|script)>/i', '', $error);
      return trim(preg_replace('/\s+/', ' ', strip_tags($error)));
    }
    else
    {
      $json = json_decode($error);
      return isset($json->error->message) ? strval($json->error->message) : $error;
    }
  }
Clean error message from Google API

@param String $error Error message HTML or JSON from Google API