diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 4675988df..76a33eb30 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -233,6 +233,10 @@ public List SearchForNewArtist(string title) return httpResponse.Resource.SelectList(MapSearchResult); } + catch (SkyHookException) + { + throw; + } catch (HttpException ex) { _logger.Warn(ex); @@ -310,11 +314,14 @@ public List SearchForNewAlbum(string title, string artist) { if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable) { - _logger.Warn("Album search failed for '{0}', service temporarily unavailable", title); - return new List(); + throw new SkyHookException("Search for '{0}' failed. LidarrAPI Temporarily Unavailable (503)", title); } - throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI.", title); + throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI. {1}", ex, title, ex.Message); + } + catch (SkyHookException) + { + throw; } catch (Exception ex) { @@ -346,51 +353,34 @@ public List SearchForNewEntity(string title) if (IsMbidQuery(lowerTitle)) { - List artist = null; try { - artist = SearchForNewArtist(lowerTitle); - } - catch (SkyHookException ex) - { - _logger.Warn(ex, $"Artist search failed for '{lowerTitle}', will try album search."); - } - catch (Exception ex) - { - _logger.Warn(ex, $"Artist search failed for '{lowerTitle}', will try album search."); - } - - if (artist != null && artist.Any()) - { - return new List { artist.First() }; - } - - try - { - var album = SearchForNewAlbum(lowerTitle, null); - if (album.Any()) + var artist = SearchForNewArtist(lowerTitle); + if (artist.Any()) { - var result = album.Where(x => x.AlbumReleases.Value.Any()).FirstOrDefault(); - if (result != null) - { - return new List { result }; - } - else - { - return new List(); - } + return new List { artist.First() }; } } - catch (SkyHookException ex) + catch (Exception) { - _logger.Warn(ex, $"Album search failed for '{lowerTitle}'."); - throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI. {1}", ex, title, ex.Message); + _logger.Debug("Artist search failed for '{0}', trying album search", lowerTitle); } - catch (Exception ex) + + var album = SearchForNewAlbum(lowerTitle, null); + if (album.Any()) { - _logger.Warn(ex, $"Album search failed for '{lowerTitle}'."); - throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI. {1}", ex, title, ex.Message); + var result = album.Where(x => x.AlbumReleases.Value.Any()).FirstOrDefault(); + if (result != null) + { + return new List { result }; + } + else + { + return new List(); + } } + + return new List(); } try @@ -411,11 +401,14 @@ public List SearchForNewEntity(string title) { if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable) { - _logger.Warn("Entity search failed for '{0}', service temporarily unavailable", title); - return new List(); + throw new SkyHookException("Search for '{0}' failed. LidarrAPI Temporarily Unavailable (503)", title); } - throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI.", title); + throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI. {1}", ex, title, ex.Message); + } + catch (SkyHookException) + { + throw; } catch (Exception ex) {