Fixed: Better import error messages

Ronnie 7 years ago committed by Mark McDowall
parent 7345811115
commit 73cb789f59
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0

@ -0,0 +1,29 @@
using System;
using System.IO;
using System.Runtime.Serialization;
namespace NzbDrone.Common.Disk
{
public class DestinationAlreadyExistsException : IOException
{
public DestinationAlreadyExistsException()
{
}
public DestinationAlreadyExistsException(string message) : base(message)
{
}
public DestinationAlreadyExistsException(string message, int hresult) : base(message, hresult)
{
}
public DestinationAlreadyExistsException(string message, Exception innerException) : base(message, innerException)
{
}
protected DestinationAlreadyExistsException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

@ -1,10 +1,11 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using NLog;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Exceptions;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Disk
@ -340,7 +341,7 @@ namespace NzbDrone.Common.Disk
}
else
{
throw new IOException(string.Format("Destination already exists. [{0}] to [{1}]", sourcePath, targetPath));
throw new DestinationAlreadyExistsException($"Destination {targetPath} already exists.");
}
}
}

@ -92,6 +92,7 @@
<Compile Include="EnvironmentInfo\IOsVersionAdapter.cs" />
<Compile Include="EnvironmentInfo\IPlatformInfo.cs" />
<Compile Include="EnvironmentInfo\OsVersionModel.cs" />
<Compile Include="Disk\DestinationAlreadyExistsException.cs" />
<Compile Include="Exceptions\SonarrStartupException.cs" />
<Compile Include="Extensions\DictionaryExtensions.cs" />
<Compile Include="Disk\OsPath.cs" />

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -12,6 +12,7 @@ using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Common;
namespace NzbDrone.Core.MediaFiles
{
@ -157,7 +158,7 @@ namespace NzbDrone.Core.MediaFiles
if (!_diskProvider.FolderExists(rootFolder))
{
throw new DirectoryNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder));
throw new EpisodeImport.RootFolderNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder));
}
var changed = false;

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Download;
using NzbDrone.Core.Extras;
using NzbDrone.Common.Exceptions;
namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
@ -122,6 +122,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
_eventAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile, oldFiles, newDownload, downloadClientItem));
}
catch (RootFolderNotFoundException e)
{
_logger.Warn(e, "Couldn't import episode " + localEpisode);
importResults.Add(new ImportResult(importDecision, "Failed to import episode, Root folder missing."));
}
catch (DestinationAlreadyExistsException e)
{
_logger.Warn(e, "Couldn't import episode " + localEpisode);
importResults.Add(new ImportResult(importDecision, "Failed to import episode, Destination already exists."));
}
catch (Exception e)
{
_logger.Warn(e, "Couldn't import episode " + localEpisode);

@ -0,0 +1,25 @@
using System;
using System.IO;
using System.Runtime.Serialization;
namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
public class RootFolderNotFoundException : DirectoryNotFoundException
{
public RootFolderNotFoundException()
{
}
public RootFolderNotFoundException(string message) : base(message)
{
}
public RootFolderNotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
protected RootFolderNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

@ -782,6 +782,7 @@
<Compile Include="MediaFiles\EpisodeImport\Manual\ManualImportService.cs" />
<Compile Include="MediaFiles\EpisodeImport\DetectSample.cs" />
<Compile Include="MediaFiles\EpisodeImport\Manual\ManuallyImportedFile.cs" />
<Compile Include="MediaFiles\EpisodeImport\RootFolderNotFoundException.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\FreeSpaceSpecification.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\SameFileSpecification.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\GrabbedReleaseQualitySpecification.cs" />

Loading…
Cancel
Save