From 560c791802d3c7b799aced9ab9dca2f7b76e6968 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev <6499856+snechaev@users.noreply.github.com> Date: Fri, 24 Oct 2025 18:06:55 +0200 Subject: [PATCH] Update the `ThrowIfExitCodeNotZero()` to check the exit code before handling cancellation. This preserves the original semantics and contract (throw only if the ffprobe exits with a non-zero code). --- FFMpegCore/FFProbe/FFProbe.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FFMpegCore/FFProbe/FFProbe.cs b/FFMpegCore/FFProbe/FFProbe.cs index ba08346..5f275d2 100644 --- a/FFMpegCore/FFProbe/FFProbe.cs +++ b/FFMpegCore/FFProbe/FFProbe.cs @@ -214,11 +214,11 @@ public static class FFProbe private static void ThrowIfExitCodeNotZero(IProcessResult result, CancellationToken cancellationToken = default) { - // if cancellation requested, then we are not interested in the exit code, just throw the cancellation exception - // to get consistent and expected behavior. - cancellationToken.ThrowIfCancellationRequested(); if (result.ExitCode != 0) { + // if cancellation requested, then we are not interested in the exit code, just throw the cancellation exception + // to get consistent and expected behavior. + cancellationToken.ThrowIfCancellationRequested(); var message = $"ffprobe exited with non-zero exit-code ({result.ExitCode} - {string.Join("\n", result.ErrorData)})"; throw new FFMpegException(FFMpegExceptionType.Process, message, null, string.Join("\n", result.ErrorData)); }