/// <summary> /// Constructs a new AppsException to be parsed from the specified /// GDataRequestException. /// </summary> /// <param name="e"></param> /// <seealso cref="ParseAppsException(GDataRequestException)"/> public AppsException(GDataRequestException e) : base("A Google Apps error occurred.", e) { this.errorCode = null; this.invalidInput = null; this.reason = null; }
public void ResponseTest() { GDataRequestException target = new GDataRequestException(); // TODO: Initialize to an appropriate value WebResponse actual; actual = target.Response; Assert.IsNull(actual); }
public void GDataRequestExceptionConstructorTest() { string msg = "TestValue"; // TODO: Initialize to an appropriate value WebException exception = new WebException(); GDataRequestException target = new GDataRequestException(msg, exception); Assert.IsNotNull(target); Assert.AreEqual(msg, target.Message); Assert.AreEqual(exception, target.InnerException); }
public static GDataError ParseError(this GDataRequestException exception) { try { var doc = XDocument.Parse(exception.ResponseString); return(doc.Elements("AppsForYourDomainErrors").Elements("error") .Select(x => new GDataError(x.Attribute("errorCode").Value, x.Attribute("reason").Value)) .SingleOrDefault()); } catch //failed to parse XML as expected { return(new GDataError(string.Empty, exception.ResponseString)); } }
/// <summary> /// Parses a GDataRequestException, which wraps the HTTP /// error responses, into an AppsException. /// </summary> /// <param name="e">the GDataRequestException to parse</param> /// <returns>a new AppsException object. The object's ErrorCode, /// InvalidInput and Reason properties will be set if the XML /// in the HTTP response could be parsed, or null otherwise.</returns> public static AppsException ParseAppsException(GDataRequestException e) { AppsException result = null; if (e == null) { return(null); } if (e.ResponseString == null) { return(null); } try { XmlReader reader = new XmlTextReader(e.ResponseString, XmlNodeType.Document, null); // now find the ErrorElement while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.LocalName == AppsNameTable.AppsError) { result = new AppsException(e); result.ErrorCode = reader.GetAttribute(AppsNameTable.AppsErrorErrorCode); result.InvalidInput = reader.GetAttribute(AppsNameTable.AppsErrorInvalidInput); result.Reason = reader.GetAttribute(AppsNameTable.AppsErrorReason); break; } } } catch (XmlException) { } return(result); }
private void ShowError(Exception ex, Label lbl, MultiView mv, View vw) { lbl.Text = ex.Message; mv.SetActiveView(vw); if (ex is Google.GData.Client.GDataRequestException) { GDataRequestException googleException = ex as Google.GData.Client.GDataRequestException; if (googleException != null && googleException.InnerException != null) { lbl.Text = googleException.InnerException.Message; } } if (lbl.Text.Contains("401")) { lbl.Text += Resources.GoogleIntegrationControl_TokenError_Text; } if (lbl.Text.Contains("403")) { lbl.Text += string.Format(Resources.GoogleIntegrationControl_DomainError_Text, ResolveUrl("~/mc/admin/organizationprofile.aspx")); } }