Improve error message when deleting a profile that is in use

Mark McDowall 7 years ago
parent bcf45bb68a
commit b529270f71

@ -1,13 +1,13 @@
using NzbDrone.Common.Exceptions; using System.Net;
using NzbDrone.Core.Exceptions;
namespace NzbDrone.Core.Profiles namespace NzbDrone.Core.Profiles
{ {
public class ProfileInUseException : NzbDroneException public class ProfileInUseException : NzbDroneClientException
{ {
public ProfileInUseException(int profileId) public ProfileInUseException(string name)
: base("Profile [{0}] is in use.", profileId) : base(HttpStatusCode.BadRequest, "Profile [{0}] is in use.", name)
{ {
} }
} }
} }

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Lifecycle;
@ -46,7 +46,8 @@ namespace NzbDrone.Core.Profiles
{ {
if (_seriesService.GetAllSeries().Any(c => c.ProfileId == id)) 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); _profileRepository.Delete(id);

Loading…
Cancel
Save