/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> /// <param name="captchaToken">The captcha token, if applicable.</param> /// <param name="captchaUrl">The captcha url, if applicable.</param> /// <param name="info">Additional information about the error code.</param> /// <param name="message">An additional error message for this exception, /// added by the code throwing this exception.</param> /// <param name="innerException">An inner exception that this exception /// will wrap around.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl, string captchaToken, Uri captchaUrl, string info, string message, Exception innerException) : base(message, innerException) { this.errorCode = standardErrorCode; this.errorUrl = errorUrl; this.captchaToken = captchaToken; this.captchaUrl = captchaUrl; this.info = info; }
/// <summary> /// Protected constructor, used by serialization frameworks while /// deserializing an exception object. /// </summary> /// <param name="info">Info about the serialization context. /// </param> /// <param name="context">A streaming context that represents the /// serialization stream.</param> /// <exception cref="ArgumentNullException">Thrown if /// <paramref name="info"/> is null.</exception> protected AuthTokenException(SerializationInfo info, StreamingContext context) : base(info, context) { if (info == null) { throw new ArgumentNullException("info"); } this.errorCode = (AuthTokenErrorCode)info.GetValue("ErrorCode", typeof(AuthTokenErrorCode)); this.errorUrl = (Uri)info.GetValue("ErrorUrl", typeof(Uri)); this.captchaToken = (string)info.GetValue("CaptchaToken", typeof(string)); this.captchaUrl = (Uri)info.GetValue("CaptchaUrl", typeof(Uri)); this.info = (string)info.GetValue("Info", typeof(string)); }
/// <summary> /// Extracts a ClientLogin failure and wraps it into /// an AuthTokenException. /// </summary> /// <param name="ex">The exception originally thrown by webrequest /// to ClientLogin endpoint.</param> /// <returns></returns> private AuthTokenException ExtractException(WebException ex, string contents) { Uri url = null; string error = String.Empty; string captchaToken = String.Empty; Uri captchaUrl = null; string info = String.Empty; string errorMessage = CommonErrorMessages.AuthTokenLoginFailed; AuthTokenErrorCode errCode = AuthTokenErrorCode.Unknown; try { Dictionary <string, string> tblResponse = ParseResponse(contents); if (tblResponse.ContainsKey("Url")) { url = new Uri(tblResponse["Url"]); } if (tblResponse.ContainsKey("Error")) { error = tblResponse["Error"]; } if (tblResponse.ContainsKey("CaptchaToken")) { captchaToken = tblResponse["CaptchaToken"]; } if (tblResponse.ContainsKey("CaptchaUrl")) { captchaUrl = new Uri(CaptchaUrlPrefix + tblResponse["CaptchaUrl"]); } try { errCode = (AuthTokenErrorCode)Enum.Parse(typeof(AuthTokenErrorCode), error, true); } catch (ArgumentException) { // Enum does not have a tryParse. } if (tblResponse.ContainsKey("Info")) { info = tblResponse["Info"]; } } catch (Exception) { errorMessage = CommonErrorMessages.FailedToParseAuthTokenException; } return(new AuthTokenException(errCode, url, captchaToken, captchaUrl, info, errorMessage, ex)); }
/// <summary> /// Protected constructor, used by serialization frameworks while /// deserializing an exception object. /// </summary> /// <param name="info">Info about the serialization context. /// </param> /// <param name="context">A streaming context that represents the /// serialization stream.</param> /// <exception cref="ArgumentNullException">Thrown if /// <paramref name="info"/> is null.</exception> protected AuthTokenException(SerializationInfo info, StreamingContext context) : base(info, context) { if (info == null) { throw new ArgumentNullException("info"); } this.errorCode = (AuthTokenErrorCode) info.GetValue("ErrorCode", typeof(AuthTokenErrorCode)); this.errorUrl = (Uri) info.GetValue("ErrorUrl", typeof(Uri)); this.captchaToken = (string) info.GetValue("CaptchaToken", typeof(string)); this.captchaUrl = (Uri) info.GetValue("CaptchaUrl", typeof(Uri)); this.info = (string) info.GetValue("Info", typeof(string)); }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> /// <param name="captchaToken">The captcha token, if applicable.</param> /// <param name="captchaUrl">The captcha url, if applicable.</param> /// <param name="info">Additional information about the error code.</param> /// <param name="message">An additional error message for this exception, /// added by the code throwing this exception.</param> /// <param name="innerException">An inner exception that this exception /// will wrap around.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl, string captchaToken, Uri captchaUrl, string info, string message, Exception innerException) : base(message, innerException) { this.errorCode = standardErrorCode; this.errorUrl = errorUrl; this.captchaToken = captchaToken; this.captchaUrl = captchaUrl; this.info = info; }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> /// <param name="captchaToken">The captcha token, if applicable.</param> /// <param name="captchaUrl">The captcha url, if applicable.</param> /// <param name="info">Additional information about the error code.</param> /// <param name="message">An additional error message for this exception, /// added by the code throwing this exception.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl, string captchaToken, Uri captchaUrl, string info, string message) : this(standardErrorCode, errorUrl, captchaToken, captchaUrl, info, message, null) { }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> /// <param name="captchaToken">The captcha token, if applicable.</param> /// <param name="captchaUrl">The captcha url, if applicable.</param> /// <param name="info">Additional information about the error code.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl, string captchaToken, Uri captchaUrl, string info) : this(standardErrorCode, errorUrl, captchaToken, captchaUrl, info, String.Empty, null) { }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl) : this(standardErrorCode, errorUrl, String.Empty, null, String.Empty, String.Empty, null) { }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> /// <param name="captchaToken">The captcha token, if applicable.</param> /// <param name="captchaUrl">The captcha url, if applicable.</param> /// <param name="info">Additional information about the error code.</param> /// <param name="message">An additional error message for this exception, /// added by the code throwing this exception.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl, string captchaToken, Uri captchaUrl, string info, string message) : this(standardErrorCode, errorUrl, captchaToken, captchaUrl, info, message, null) { }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> /// <param name="captchaToken">The captcha token, if applicable.</param> /// <param name="captchaUrl">The captcha url, if applicable.</param> /// <param name="info">Additional information about the error code.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl, string captchaToken, Uri captchaUrl, string info) : this(standardErrorCode, errorUrl, captchaToken, captchaUrl, info, String.Empty, null) { }
/// <summary> /// Public constructor. /// </summary> /// <param name="standardErrorCode">The error code for this exception. /// </param> /// <param name="errorUrl">The error url for this exception.</param> public AuthTokenException(AuthTokenErrorCode standardErrorCode, Uri errorUrl) : this(standardErrorCode, errorUrl, String.Empty, null, String.Empty, String.Empty, null) { }