From f435f38a2725dd9667bc6cfec956dc2715c3c4ac Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 19 Dec 2025 09:05:54 -0600 Subject: [PATCH] Fix remaining technical debt bugs - Bug-001: Add null check for SingleOrDefault() in TorrentRssParser - Bug-006: Replace generic Exception with PathCombinationException in OsPath - Bug-006: Replace generic Exception with NotSupportedException in IMDbListRequestGenerator --- src/NzbDrone.Common/Disk/OsPath.cs | 2 +- .../Disk/PathCombinationException.cs | 17 +++++++++++++++++ .../IMDb/IMDbListRequestGenerator.cs | 2 +- src/NzbDrone.Core/Indexers/TorrentRssParser.cs | 5 ++++- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/NzbDrone.Common/Disk/PathCombinationException.cs diff --git a/src/NzbDrone.Common/Disk/OsPath.cs b/src/NzbDrone.Common/Disk/OsPath.cs index a219c4ac77..677316b368 100644 --- a/src/NzbDrone.Common/Disk/OsPath.cs +++ b/src/NzbDrone.Common/Disk/OsPath.cs @@ -421,7 +421,7 @@ public bool Equals(OsPath other, bool ignoreTrailingSlash) { if (left.Kind != right.Kind && right.Kind != OsPathKind.Unknown) { - throw new Exception(string.Format("Cannot combine OsPaths of different platforms ('{0}' + '{1}')", left, right)); + throw new PathCombinationException("Cannot combine OsPaths of different platforms ('{0}' + '{1}')", left, right); } if (right.IsEmpty) diff --git a/src/NzbDrone.Common/Disk/PathCombinationException.cs b/src/NzbDrone.Common/Disk/PathCombinationException.cs new file mode 100644 index 0000000000..772a6e29d6 --- /dev/null +++ b/src/NzbDrone.Common/Disk/PathCombinationException.cs @@ -0,0 +1,17 @@ +using NzbDrone.Common.Exceptions; + +namespace NzbDrone.Common.Disk +{ + public class PathCombinationException : NzbDroneException + { + public PathCombinationException(string message, params object[] args) + : base(message, args) + { + } + + public PathCombinationException(string message) + : base(message) + { + } + } +} diff --git a/src/NzbDrone.Core/ImportLists/RadarrList2/IMDb/IMDbListRequestGenerator.cs b/src/NzbDrone.Core/ImportLists/RadarrList2/IMDb/IMDbListRequestGenerator.cs index ba1afdf10c..feaf53fc85 100644 --- a/src/NzbDrone.Core/ImportLists/RadarrList2/IMDb/IMDbListRequestGenerator.cs +++ b/src/NzbDrone.Core/ImportLists/RadarrList2/IMDb/IMDbListRequestGenerator.cs @@ -14,7 +14,7 @@ protected override HttpRequest GetHttpRequest() // Use IMDb list Export for user lists to bypass RadarrAPI caching if (Settings.ListId.StartsWith("ls", StringComparison.OrdinalIgnoreCase)) { - throw new Exception("IMDb lists of the form 'ls12345678' are no longer supported. Feel free to remove this list after you review your Clean Library Level."); + throw new NotSupportedException("IMDb lists of the form 'ls12345678' are no longer supported. Feel free to remove this list after you review your Clean Library Level."); } var request = RequestBuilder.Create() diff --git a/src/NzbDrone.Core/Indexers/TorrentRssParser.cs b/src/NzbDrone.Core/Indexers/TorrentRssParser.cs index e473b3407f..610a132018 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRssParser.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRssParser.cs @@ -168,7 +168,10 @@ protected virtual string GetMagnetUrl(XElement item) if (PeersElementName.IsNotNullOrWhiteSpace()) { var itempeers = item.FindDecendants(PeersElementName).SingleOrDefault(); - return int.Parse(itempeers.Value); + if (itempeers != null) + { + return int.Parse(itempeers.Value); + } } return null;