From b529270f716607ef0ed343c2343003a99370d28b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 10 Feb 2018 10:14:28 -0800 Subject: [PATCH] Improve error message when deleting a profile that is in use --- src/NzbDrone.Core/Profiles/ProfileInUseException.cs | 12 ++++++------ src/NzbDrone.Core/Profiles/ProfileService.cs | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/NzbDrone.Core/Profiles/ProfileInUseException.cs b/src/NzbDrone.Core/Profiles/ProfileInUseException.cs index d55523d9a..b48488a4d 100644 --- a/src/NzbDrone.Core/Profiles/ProfileInUseException.cs +++ b/src/NzbDrone.Core/Profiles/ProfileInUseException.cs @@ -1,13 +1,13 @@ -using NzbDrone.Common.Exceptions; +using System.Net; +using NzbDrone.Core.Exceptions; namespace NzbDrone.Core.Profiles { - public class ProfileInUseException : NzbDroneException + public class ProfileInUseException : NzbDroneClientException { - public ProfileInUseException(int profileId) - : base("Profile [{0}] is in use.", profileId) + public ProfileInUseException(string name) + : base(HttpStatusCode.BadRequest, "Profile [{0}] is in use.", name) { - } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Profiles/ProfileService.cs b/src/NzbDrone.Core/Profiles/ProfileService.cs index 89c569ff1..b5da50ab4 100644 --- a/src/NzbDrone.Core/Profiles/ProfileService.cs +++ b/src/NzbDrone.Core/Profiles/ProfileService.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Lifecycle; @@ -46,7 +46,8 @@ namespace NzbDrone.Core.Profiles { if (_seriesService.GetAllSeries().Any(c => c.ProfileId == id)) { - throw new ProfileInUseException(id); + var profile = _profileRepository.Get(id); + throw new ProfileInUseException(profile.Name); } _profileRepository.Delete(id); @@ -125,4 +126,4 @@ namespace NzbDrone.Core.Profiles Quality.Bluray1080p); } } -} \ No newline at end of file +}