Beispiel #1
0
        /// <summary>
        /// Parses the error response into an exception.
        /// </summary>
        /// <param name="errorsXml">The errors XML.</param>
        /// <param name="e">The original exception.</param>
        /// <returns>An AdWords Reports exception that represents the error.</returns>
        private AdWordsReportsException ParseException(Exception e, string contents)
        {
            List <ReportDownloadError> errorList = new List <ReportDownloadError>();

            try {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(contents);
                XmlNodeList errorNodes = xDoc.DocumentElement.SelectNodes("ApiError");
                foreach (XmlElement errorNode in errorNodes)
                {
                    ReportDownloadError downloadError = new ReportDownloadError();
                    downloadError.ErrorType = errorNode.SelectSingleNode("type").InnerText;
                    downloadError.FieldPath = errorNode.SelectSingleNode("fieldPath").InnerText;
                    downloadError.Trigger   = errorNode.SelectSingleNode("trigger").InnerText;

                    errorList.Add(downloadError);
                }
            } catch {
            }
            AdWordsReportsException ex = new AdWordsReportsException(
                "Report download errors occurred.", e);

            ex.Errors = errorList.ToArray();
            return(ex);
        }
        /// <summary>
        /// Parses the error response into an exception.
        /// </summary>
        /// <param name="exception">The original exception.</param>
        /// <param name="contents">The errors XML.</param>
        /// <returns>An AdWords Reports exception that represents the error.</returns>
        private AdWordsReportsException ParseException(Exception exception, string contents)
        {
            List <ReportDownloadError> errorList = new List <ReportDownloadError>();

            try
            {
                XmlDocument xDoc       = XmlUtilities.CreateDocument(contents);
                XmlNodeList errorNodes = xDoc.DocumentElement.SelectNodes("ApiError");
                foreach (XmlElement errorNode in errorNodes)
                {
                    ReportDownloadError downloadError = new ReportDownloadError();
                    downloadError.ErrorType = errorNode.SelectSingleNode("type").InnerText;
                    downloadError.FieldPath = errorNode.SelectSingleNode("fieldPath").InnerText;
                    downloadError.Trigger   = errorNode.SelectSingleNode("trigger").InnerText;
                    errorList.Add(downloadError);
                }
            }
            catch
            {
            }

            AdWordsReportsException retval = new AdWordsReportsException(this.reportVersion,
                                                                         AdWordsErrorMessages.ReportingExceptionOccurred, exception);

            retval.Errors = errorList.ToArray();
            return(retval);
        }
        /// <summary>
        /// Parses the error response into an exception.
        /// </summary>
        /// <param name="errors">The error response from the server.</param>
        /// <returns></returns>
        private ReportsException ParseException(string errorsXml)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(errorsXml);
            XmlNodeList errorNodes = xDoc.DocumentElement.SelectNodes("ApiError");
            List <ReportDownloadError> errorList = new List <ReportDownloadError>();

            foreach (XmlElement errorNode in errorNodes)
            {
                ReportDownloadError downloadError = new ReportDownloadError();
                downloadError.ErrorType = errorNode.SelectSingleNode("type").InnerText;
                downloadError.FieldPath = errorNode.SelectSingleNode("fieldPath").InnerText;
                downloadError.Trigger   = errorNode.SelectSingleNode("trigger").InnerText;

                errorList.Add(downloadError);
            }
            ReportsException ex = new ReportsException("Report download errors occurred, see errors " +
                                                       "field for more details.");

            ex.Errors = errorList.ToArray();
            return(ex);
        }
        /// <summary>
        /// Parses the error response into an exception.
        /// </summary>
        /// <param name="exception">The original exception.</param>
        /// <param name="contents">The errors XML.</param>
        /// <returns>An AdWords Reports exception that represents the error.</returns>
        private AdWordsReportsException ParseException(Exception exception, string contents)
        {
            List<ReportDownloadError> errorList = new List<ReportDownloadError>();
              try {
            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(contents);
            XmlNodeList errorNodes = xDoc.DocumentElement.SelectNodes("ApiError");
            foreach (XmlElement errorNode in errorNodes) {
              ReportDownloadError downloadError = new ReportDownloadError();
              downloadError.ErrorType = errorNode.SelectSingleNode("type").InnerText;
              downloadError.FieldPath = errorNode.SelectSingleNode("fieldPath").InnerText;
              downloadError.Trigger = errorNode.SelectSingleNode("trigger").InnerText;

              errorList.Add(downloadError);
            }
              } catch {
              }
              AdWordsReportsException retval = new AdWordsReportsException(
              "Report download errors occurred.", exception);
              retval.Errors = errorList.ToArray();
              return retval;
        }