public ApiOAuthException(string message, OAuthException innerException) : base(message, innerException) { OAuthProblemReport report = innerException.Report; Problem = report.Problem; Advice = report.ProblemAdvice; }
public static Exception MissingRequiredOAuthParameter(IOAuthContext context, string parameterName) { var exception = new OAuthException(context, OAuthProblems.ParameterAbsent, string.Format("Missing required parameter : {0}", parameterName)); exception.Report.ParametersAbsent.Add(parameterName); return(exception); }
public static Exception MissingRequiredOAuthParameter(IOAuthContext context, string parameterName) { var exception = new OAuthException(context, OAuthProblems.ParameterAbset, string.Format("Missing required parameter : {0}", parameterName)); exception.Report.ParametersAbsent.Add(parameterName); return exception; }
/// <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> /// <returns><c>true</c>, if the authException should be throw, <c>false</c> if the original web exception should be thrown</returns> public static bool TryWrapException(IOAuthContext requestContext, WebException webEx, out OAuthException authException) { try { string content = webEx.Response.ReadToEnd(); 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> /// 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="webException"></param> /// <param name="wrappedException">The wrapped exception (will be set to the webException, if this method returns <c>false</c></param> /// <returns><c>true</c>, if the authException should be throw, <c>false</c> if the wrapped web exception should be thrown</returns> public static bool TryWrapException(IOAuthContext requestContext, WebException webException, out Exception wrappedException) { try { string content = webException.Response.ReadToEnd(); if (content.Contains(Parameters.OAuth_Problem)) { var report = new OAuthProblemReport(content); wrappedException = new OAuthException(report.ProblemAdvice ?? report.Problem, webException) { Context = requestContext, Report = report }; } else { wrappedException = new ParsedWebException(content, webException.Message, webException.GetBaseException(), webException.Status, webException.Response); } return true; } catch { wrappedException = webException; return false; } }
static XElement GetHtmlFormattedErrorReport(OAuthException authEx) { // TODO: Review OAuth error reporting extension, I don't think it allows for html formatting of the error report. string reportAsHtmlDocument = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" version=\"-//W3C//DTD XHTML 2.0//EN\" xml:lang=\"en\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd\">" + "<HEAD><TITLE>Request Error</TITLE></HEAD><BODY><DIV id=\"content\"><P class=\"heading1\"><B>" + HttpUtility.HtmlEncode(authEx.Report.ToString()) + "</B></P></DIV></BODY></html>"; return XElement.Load(new StringReader(reportAsHtmlDocument)); }
public ApiOAuthException(OAuthException innerException) : this(innerException.Message, innerException) { }