From acb6fc01b3196c1a4795f9de9181c9910d1a62a4 Mon Sep 17 00:00:00 2001 From: ta264 Date: Wed, 17 Mar 2021 21:35:42 +0000 Subject: [PATCH] Fixed: Gracefully handle Goodreads search error Fixes #897 --- .../Identification/CandidateServiceFixture.cs | 41 +++++++++++++++++++ .../Identification/CandidateService.cs | 6 +-- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs new file mode 100644 index 000000000..7d01732f3 --- /dev/null +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.MediaFiles.BookImport.Identification; +using NzbDrone.Core.MetadataSource; +using NzbDrone.Core.MetadataSource.Goodreads; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification +{ + [TestFixture] + public class CandidateServiceFixture : CoreTest + { + [Test] + public void should_not_throw_on_goodreads_exception() + { + Mocker.GetMock() + .Setup(s => s.SearchForNewBook(It.IsAny(), It.IsAny())) + .Throws(new GoodreadsException("Bad search")); + + var edition = new LocalEdition + { + LocalBooks = new List + { + new LocalBook + { + FileTrackInfo = new ParsedTrackInfo + { + AuthorTitle = "Author", + BookTitle = "Book" + } + } + } + }; + + Subject.GetRemoteCandidates(edition).Should().BeEmpty(); + } + } +} diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs index 3a1c25684..dd3024124 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs @@ -4,7 +4,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Books; using NzbDrone.Core.MetadataSource; -using NzbDrone.Core.MetadataSource.SkyHook; +using NzbDrone.Core.MetadataSource.Goodreads; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.MediaFiles.BookImport.Identification @@ -258,9 +258,9 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification } } } - catch (SkyHookException e) + catch (GoodreadsException e) { - _logger.Info(e, "Skipping book due to SkyHook error"); + _logger.Info(e, "Skipping book due to Goodreads error"); remoteBooks = new List(); }