internal static void BuildAndThrowTwitterQueryException(string responseStr, HttpResponseMessage msg)
        {
            TwitterErrorDetails error = ParseTwitterErrorMessage(responseStr);

            throw new TwitterQueryException(error.Message)
                  {
                      ErrorCode    = error.Code,
                      StatusCode   = msg.StatusCode,
                      ReasonPhrase = msg.ReasonPhrase
                  };
        }
        internal static void BuildAndThrowTwitterQueryException(string responseStr, HttpResponseMessage msg)
        {
            TwitterErrorDetails error = ParseTwitterErrorMessage(responseStr);

            string title = error?.Title ?? string.Empty;

            throw new TwitterQueryException(title)
                  {
                      StatusCode   = msg.StatusCode,
                      ReasonPhrase = msg.ReasonPhrase,
                      Title        = title,
                      Details      = error?.Detail ?? string.Empty,
                      Type         = error?.Type ?? string.Empty,
                      Errors       = error?.Errors ?? new List <Error>()
                  };
        }
        internal async static Task HandleUnauthorizedAsync(HttpResponseMessage msg)
        {
            string responseStr = await msg.Content.ReadAsStringAsync().ConfigureAwait(false);

            TwitterErrorDetails error = ParseTwitterErrorMessage(responseStr);

            string message = error.Message + " - Please visit the LINQ to Twitter FAQ (at the HelpLink) for help on resolving this error.";

            throw new TwitterQueryException(message)
                  {
                      HelpLink     = L2TKeys.FaqHelpUrl,
                      ErrorCode    = error.Code,
                      StatusCode   = HttpStatusCode.Unauthorized,
                      ReasonPhrase = msg.ReasonPhrase
                  };
        }
Esempio n. 4
0
        internal static async Task HandleTooManyRequestsAsync(HttpResponseMessage msg)
        {
            string responseStr = await msg.Content.ReadAsStringAsync().ConfigureAwait(false);

            TwitterErrorDetails error = ParseTwitterErrorMessage(responseStr);

            string message = error.Detail + " - Please visit the LINQ to Twitter FAQ (at the HelpLink) for help on resolving this error.";

            throw new TwitterQueryException(message)
                  {
                      HelpLink     = L2TKeys.FaqHelpUrl,
                      Type         = error.Type,
                      StatusCode   = HttpStatusCode.SeeOther,
                      ReasonPhrase = msg.ReasonPhrase + " (HTTP 429 - Too Many Requests)"
                  };
        }