/// <summary> /// Will attempt to wrap the exception, returning true if the exception was wrapped, or returning false if it was not (in which case /// the original exception should be thrown). /// </summary> /// <param name="requestContext"></param> /// <param name="webEx"></param> /// <param name="authException"></param> /// <param name="responseBodyAction"></param> /// <returns></returns> public static bool TryWrapException(IOAuthContext requestContext, WebException webEx, out OAuthException authException, Action <string> responseBodyAction) { try { string content = webEx.Response.ReadToEnd(); if (responseBodyAction != null) { responseBodyAction(content); } if (content.Contains(Parameters.OAuth_Problem)) { var report = new OAuthProblemReport(content); authException = new OAuthException(report.ProblemAdvice ?? report.Problem, webEx) { Context = requestContext, Report = report }; return(true); } } catch { } authException = new OAuthException(); return(false); }
/// <summary> /// OAuth execption. /// </summary> /// <param name="problem">The problem</param> /// <param name="advice">The advice.</param> /// <param name="innerException">The inner exception.</param> public OAuthException(string problem, string advice, Exception innerException) : base(advice, innerException) { Report = new OAuthProblemReport { Problem = problem, ProblemAdvice = advice }; }
/// <summary> /// OAuth execption. /// </summary> /// <param name="context">The OAuth context</param> /// <param name="problem">The problem</param> /// <param name="advice">The advice.</param> /// <param name="innerException">The inner exception.</param> public OAuthException(IOAuthContext context, string problem, string advice, Exception innerException) : base(advice, innerException) { Context = context; Report = new OAuthProblemReport { Problem = problem, ProblemAdvice = advice }; }