mirror of
https://github.com/Lidarr/Lidarr
synced 2026-05-08 12:33:04 +02:00
Fixed: Improve Artist/Album lookup error messaging
This commit is contained in:
parent
cadb839dd0
commit
9db6cf2ce7
1 changed files with 35 additions and 42 deletions
|
|
@ -233,6 +233,10 @@ public List<Artist> SearchForNewArtist(string title)
|
||||||
|
|
||||||
return httpResponse.Resource.SelectList(MapSearchResult);
|
return httpResponse.Resource.SelectList(MapSearchResult);
|
||||||
}
|
}
|
||||||
|
catch (SkyHookException)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
_logger.Warn(ex);
|
_logger.Warn(ex);
|
||||||
|
|
@ -310,11 +314,14 @@ public List<Album> SearchForNewAlbum(string title, string artist)
|
||||||
{
|
{
|
||||||
if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
||||||
{
|
{
|
||||||
_logger.Warn("Album search failed for '{0}', service temporarily unavailable", title);
|
throw new SkyHookException("Search for '{0}' failed. LidarrAPI Temporarily Unavailable (503)", title);
|
||||||
return new List<Album>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -346,51 +353,34 @@ public List<object> SearchForNewEntity(string title)
|
||||||
|
|
||||||
if (IsMbidQuery(lowerTitle))
|
if (IsMbidQuery(lowerTitle))
|
||||||
{
|
{
|
||||||
List<Artist> artist = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artist = SearchForNewArtist(lowerTitle);
|
var artist = SearchForNewArtist(lowerTitle);
|
||||||
}
|
if (artist.Any())
|
||||||
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<object> { artist.First() };
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var album = SearchForNewAlbum(lowerTitle, null);
|
|
||||||
if (album.Any())
|
|
||||||
{
|
{
|
||||||
var result = album.Where(x => x.AlbumReleases.Value.Any()).FirstOrDefault();
|
return new List<object> { artist.First() };
|
||||||
if (result != null)
|
|
||||||
{
|
|
||||||
return new List<object> { result };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new List<object>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SkyHookException ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
_logger.Warn(ex, $"Album search failed for '{lowerTitle}'.");
|
_logger.Debug("Artist search failed for '{0}', trying album search", lowerTitle);
|
||||||
throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI. {1}", ex, title, ex.Message);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
var album = SearchForNewAlbum(lowerTitle, null);
|
||||||
|
if (album.Any())
|
||||||
{
|
{
|
||||||
_logger.Warn(ex, $"Album search failed for '{lowerTitle}'.");
|
var result = album.Where(x => x.AlbumReleases.Value.Any()).FirstOrDefault();
|
||||||
throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI. {1}", ex, title, ex.Message);
|
if (result != null)
|
||||||
|
{
|
||||||
|
return new List<object> { result };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new List<object>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new List<object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -411,11 +401,14 @@ public List<object> SearchForNewEntity(string title)
|
||||||
{
|
{
|
||||||
if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable)
|
||||||
{
|
{
|
||||||
_logger.Warn("Entity search failed for '{0}', service temporarily unavailable", title);
|
throw new SkyHookException("Search for '{0}' failed. LidarrAPI Temporarily Unavailable (503)", title);
|
||||||
return new List<object>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue