Fixed: Improve error handling for fingerprint search API failures

This commit is contained in:
bakerboy448 2025-09-02 11:57:16 -05:00
parent 3dabcab134
commit 19a1d5c62d

View file

@ -327,6 +327,8 @@ public List<Album> SearchForNewAlbum(string title, string artist)
}
public List<Album> SearchForNewAlbumByRecordingIds(List<string> recordingIds)
{
try
{
var ids = recordingIds.Where(x => x.IsNotNullOrWhiteSpace()).Distinct();
var httpRequest = _requestBuilder.GetRequestBuilder().Create()
@ -342,6 +344,21 @@ public List<Album> SearchForNewAlbumByRecordingIds(List<string> recordingIds)
.Where(x => x != null)
.ToList();
}
catch (HttpException ex)
{
if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable)
{
throw new SkyHookException("Search by fingerprint failed. LidarrAPI Temporarily Unavailable (503)");
}
throw new SkyHookException("Search by fingerprint failed. Unable to communicate with LidarrAPI. {0}", ex, ex.Message);
}
catch (Exception ex) when (ex is not SkyHookException)
{
_logger.Warn(ex, ex.Message);
throw new SkyHookException("Search by fingerprint failed. Invalid response received from LidarrAPI.");
}
}
public List<object> SearchForNewEntity(string title)
{