diff --git a/FFMpegCore/FFProbe/Exceptions/FFProbeException.cs b/FFMpegCore/FFProbe/Exceptions/FFProbeException.cs new file mode 100644 index 0000000..3495193 --- /dev/null +++ b/FFMpegCore/FFProbe/Exceptions/FFProbeException.cs @@ -0,0 +1,11 @@ +using System; + +namespace FFMpegCore.Exceptions +{ + public class FFProbeException : Exception + { + public FFProbeException(string message, Exception? inner = null) : base(message, inner) + { + } + } +} \ No newline at end of file diff --git a/FFMpegCore/FFProbe/Exceptions/FFProbeProcessException.cs b/FFMpegCore/FFProbe/Exceptions/FFProbeProcessException.cs new file mode 100644 index 0000000..5ab6b93 --- /dev/null +++ b/FFMpegCore/FFProbe/Exceptions/FFProbeProcessException.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace FFMpegCore.Exceptions +{ + public class FFProbeProcessException : FFProbeException + { + public IReadOnlyCollection ProcessErrors { get; } + + public FFProbeProcessException(string message, IReadOnlyCollection processErrors, Exception? inner = null) : base(message, inner) + { + ProcessErrors = processErrors; + } + } +} \ No newline at end of file diff --git a/FFMpegCore/FFProbe/Exceptions/FormatNullException.cs b/FFMpegCore/FFProbe/Exceptions/FormatNullException.cs new file mode 100644 index 0000000..4141f5f --- /dev/null +++ b/FFMpegCore/FFProbe/Exceptions/FormatNullException.cs @@ -0,0 +1,9 @@ +namespace FFMpegCore.Exceptions +{ + public class FormatNullException : FFProbeException + { + public FormatNullException() : base("Format not specified") + { + } + } +} \ No newline at end of file diff --git a/FFMpegCore/FFProbe/FFProbe.cs b/FFMpegCore/FFProbe/FFProbe.cs index 6fa16a1..7d043a6 100644 --- a/FFMpegCore/FFProbe/FFProbe.cs +++ b/FFMpegCore/FFProbe/FFProbe.cs @@ -93,7 +93,7 @@ public static async Task AnalyseAsync(Stream stream, int outputC } var exitCode = await task.ConfigureAwait(false); if (exitCode != 0) - throw new FFMpegException(FFMpegExceptionType.Process, $"FFProbe process returned exit status {exitCode}", null, string.Join("\n", instance.ErrorData)); + throw new FFProbeProcessException($"ffprobe exited with non-zero exit-code ({exitCode} - {string.Join("\n", instance.ErrorData)})", instance.ErrorData); pipeArgument.Post(); return ParseOutput(instance); @@ -108,7 +108,7 @@ private static IMediaAnalysis ParseOutput(Instance instance) }); if (ffprobeAnalysis?.Format == null) - throw new Exception(); + throw new FormatNullException(); return new MediaAnalysis(ffprobeAnalysis); } @@ -123,8 +123,7 @@ private static Instance PrepareInstance(string filePath, int outputCapacity, FFO StandardOutputEncoding = ffOptions.Encoding, StandardErrorEncoding = ffOptions.Encoding }; - var instance = new Instance(startInfo) - { DataBufferCapacity = outputCapacity }; + var instance = new Instance(startInfo) { DataBufferCapacity = outputCapacity }; return instance; } } diff --git a/FFMpegCore/Helpers/FFProbeHelper.cs b/FFMpegCore/Helpers/FFProbeHelper.cs index d0064e4..4989542 100644 --- a/FFMpegCore/Helpers/FFProbeHelper.cs +++ b/FFMpegCore/Helpers/FFProbeHelper.cs @@ -30,7 +30,7 @@ public static void VerifyFFProbeExists(FFOptions ffMpegOptions) var (exitCode, _) = Instance.Finish(GlobalFFOptions.GetFFProbeBinaryPath(ffMpegOptions), "-version"); _ffprobeVerified = exitCode == 0; if (!_ffprobeVerified) - throw new FFMpegException(FFMpegExceptionType.Operation, "ffprobe was not found on your system"); + throw new FFProbeException("ffprobe was not found on your system"); } } }