Exemplo n.º 1
0
 public PageReadResult(Uri uri, List <ScrapedSong>?songs, ScrapedSong?firstSong, ScrapedSong?lastSong, int songsOnPage, Exception?exception, PageErrorType pageError, bool isLastPage = false)
     : this(uri, songs, firstSong, lastSong, songsOnPage, isLastPage)
 {
     if (exception != null)
     {
         if (pageError == PageErrorType.None)
         {
             pageError = PageErrorType.Unknown;
         }
         PageError = pageError;
         if (exception is FeedReaderException frException)
         {
             Exception = frException;
         }
         else
         {
             Exception = new FeedReaderException(exception.Message, exception);
         }
     }
     else
     {
         if (pageError > PageError)
         {
             PageError = pageError;
         }
     }
 }
Exemplo n.º 2
0
        public static string ErrorToString(this PageErrorType pageError)
        {
            switch (pageError)
            {
            case PageErrorType.None:
                return(string.Empty);

            case PageErrorType.Timeout:
                return("Timeout");

            case PageErrorType.SiteError:
                return("Site Error");

            case PageErrorType.ParsingError:
                return("Parsing Error");

            case PageErrorType.PageOutOfRange:
                return("Page out of range");

            case PageErrorType.Unknown:
                return("Unknown Error");

            default:
                return("Unknown Error");
            }
        }
Exemplo n.º 3
0
        public static PageReadResult FromWebClientException(WebClientException?ex, Uri requestUri)
        {
            PageErrorType pageError  = PageErrorType.SiteError;
            string        errorText  = string.Empty;
            int           statusCode = ex?.Response?.StatusCode ?? 0;

            if (statusCode != 0)
            {
                switch (statusCode)
                {
                case 408:
                    errorText = "Timeout";
                    pageError = PageErrorType.Timeout;
                    break;

                default:
                    errorText = "Site Error";
                    pageError = PageErrorType.SiteError;
                    break;
                }
            }
            string message = $"{errorText} getting page '{requestUri}'.";

            Logger?.Debug(message);
            // No need for a stacktrace if it's one of these errors.
            if (!(pageError == PageErrorType.Timeout || statusCode == 500) && ex != null)
            {
                Logger?.Debug($"{ex.Message}\n{ex.StackTrace}");
            }
            return(new PageReadResult(requestUri, null, null, null, 0, new FeedReaderException(message, ex, FeedReaderFailureCode.PageFailed), pageError));
        }
Exemplo n.º 4
0
 public PageReadResult(Uri uri, List <ScrapedSong> songs, Exception exception, PageErrorType pageError)
     : this(uri, songs)
 {
     if (exception != null)
     {
         if (pageError == PageErrorType.None)
         {
             pageError = PageErrorType.Unknown;
         }
         PageError = pageError;
         if (exception is FeedReaderException frException)
         {
             Exception = frException;
         }
         else
         {
             Exception = new FeedReaderException(exception.Message, exception);
         }
     }
     else
     {
         if (pageError > PageError)
         {
             PageError = pageError;
         }
     }
 }
    public void AddPageError(PageErrorType enumPageErrorType, string strError)
    {
        if (enumPageErrorType == PageErrorType.WbsApiError)
            lPageErrors_WbsApi.Add(strError);

        else if (enumPageErrorType == PageErrorType.WbsPgError)
            lPageErrors_WbsPg.Add(strError);

        else if (enumPageErrorType == PageErrorType.ValidationError)
            lPageErrors_Validation.Add(strError);

        return;
    }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MeNext.Spotify.iOS.SpotifySimpleResultList`1"/> class where
 /// the operation has failed.
 /// </summary>
 /// <param name="error">Error.</param>
 public SpotifySimpleResultList(PageErrorType error)
 {
     this.items = null;
     this.error = error;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:MeNext.Spotify.iOS.SpotifySimpleResultList`1"/> class when
 /// the operation has succeeded.
 /// </summary>
 /// <param name="items">Items.</param>
 public SpotifySimpleResultList(List <K> items)
 {
     this.items = items;
     this.error = PageErrorType.SUCCESS;
 }