mirror of
https://github.com/Lidarr/Lidarr
synced 2026-05-05 02:51:40 +02:00
Add logging on list parser errors
This commit is contained in:
parent
a39512cf45
commit
9792c298d9
2 changed files with 8 additions and 4 deletions
|
|
@ -31,7 +31,7 @@ public override IImportListRequestGenerator GetRequestGenerator()
|
|||
public override IParseImportListResponse GetParser()
|
||||
{
|
||||
var parser = new DiscogsListsParser();
|
||||
parser.SetContext(_httpClient, Settings);
|
||||
parser.SetContext(_httpClient, Settings, _logger);
|
||||
return parser;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
|
|
@ -12,15 +14,17 @@ public class DiscogsListsParser : IParseImportListResponse
|
|||
{
|
||||
private IHttpClient _httpClient;
|
||||
private DiscogsListsSettings _settings;
|
||||
private Logger _logger;
|
||||
|
||||
public DiscogsListsParser()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetContext(IHttpClient httpClient, DiscogsListsSettings settings)
|
||||
public void SetContext(IHttpClient httpClient, DiscogsListsSettings settings, Logger logger = null)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_settings = settings;
|
||||
_logger = logger ?? LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
|
||||
public IList<ImportListItemInfo> ParseResponse(ImportListResponse importListResponse)
|
||||
|
|
@ -66,9 +70,9 @@ private ImportListItemInfo TryFetchRelease(string resourceUrl)
|
|||
{
|
||||
return DiscogsParserHelper.FetchReleaseDetails(_httpClient, _settings.Token, resourceUrl);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
// If we can't fetch release details, skip this item
|
||||
_logger?.Error(ex, "Failed to fetch release details from Discogs API for resource URL: {0}. Skipping this item.", resourceUrl);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue