Log partial indexer response on parser error.

pull/3113/head
Taloth Saldono 10 years ago
parent 2e6cf2b7f6
commit 25c77711cd

@ -13,7 +13,7 @@ namespace NzbDrone.Core.Indexers.Newznab
protected override bool PreProcess(IndexerResponse indexerResponse)
{
var xdoc = XDocument.Parse(indexerResponse.Content);
var xdoc = LoadXmlDocument(indexerResponse);
var error = xdoc.Descendants("error").FirstOrDefault();
if (error == null) return true;

@ -42,30 +42,48 @@ namespace NzbDrone.Core.Indexers
return releases;
}
using (var xmlTextReader = XmlReader.Create(new StringReader(indexerResponse.Content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true }))
var document = LoadXmlDocument(indexerResponse);
var items = GetItems(document);
foreach (var item in items)
{
var document = XDocument.Load(xmlTextReader);
var items = GetItems(document);
try
{
var reportInfo = ProcessItem(item);
foreach (var item in items)
releases.AddIfNotNull(reportInfo);
}
catch (Exception itemEx)
{
try
{
var reportInfo = ProcessItem(item);
releases.AddIfNotNull(reportInfo);
}
catch (Exception itemEx)
{
itemEx.Data.Add("Item", item.Title());
_logger.ErrorException("An error occurred while processing feed item from " + indexerResponse.Request.Url, itemEx);
}
itemEx.Data.Add("Item", item.Title());
_logger.ErrorException("An error occurred while processing feed item from " + indexerResponse.Request.Url, itemEx);
}
}
return releases;
}
protected virtual XDocument LoadXmlDocument(IndexerResponse indexerResponse)
{
try
{
using (var xmlTextReader = XmlReader.Create(new StringReader(indexerResponse.Content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true }))
{
return XDocument.Load(xmlTextReader);
}
}
catch (XmlException ex)
{
var contentSample = indexerResponse.Content.Substring(0, Math.Min(indexerResponse.Content.Length, 512));
_logger.Debug("Truncated response content (originally {0} characters): {1}", indexerResponse.Content.Length, contentSample);
ex.Data.Add("ContentLength", indexerResponse.Content.Length);
ex.Data.Add("ContentSample", contentSample);
throw;
}
}
protected virtual ReleaseInfo CreateNewReleaseInfo()
{
return new ReleaseInfo();

Loading…
Cancel
Save