From 9048da1dd542e3d44865aed41d6d1e48825c807f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 11 May 2012 13:50:41 -0700 Subject: [PATCH] Rss feed paring will check for errors and give a better error if found. --- .../Indexer/SyndicationFeedXmlReader.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/NzbDrone.Core/Providers/Indexer/SyndicationFeedXmlReader.cs b/NzbDrone.Core/Providers/Indexer/SyndicationFeedXmlReader.cs index 9f5136f5d..7287a4b7c 100644 --- a/NzbDrone.Core/Providers/Indexer/SyndicationFeedXmlReader.cs +++ b/NzbDrone.Core/Providers/Indexer/SyndicationFeedXmlReader.cs @@ -2,6 +2,7 @@ //https://connect.microsoft.com/VisualStudio/feedback/details/325421/syndicationfeed-load-fails-to-parse-datetime-against-a-real-world-feeds-ie7-can-read using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; @@ -33,6 +34,8 @@ namespace NzbDrone.Core.Providers.Indexer _isRss2DateTime = rss20DateTimeHints.Contains(localname); _isAtomDateTime = atom10DateTimeHints.Contains(localname); + CheckForError(); + return base.IsStartElement(localname, ns); } @@ -70,5 +73,30 @@ namespace NzbDrone.Core.Providers.Indexer return dateVal; } + + internal void CheckForError() + { + if (this.MoveToContent() == XmlNodeType.Element) + { + if (this.Name != "error") + return; + + var message = "Error: "; + + if (this.HasAttributes) + { + var attributes = new Dictionary(); + + while (this.MoveToNextAttribute()) + { + message += String.Format(" [{0}:{1}]", this.Name, this.Value); + } + } + + logger.Error("Error in RSS feed: {0}", message); + throw new Exception(message); + } + + } } }