Skip to content

Commit 511323f

Browse files
authored
Fix generic catch clause to preserve exception stack traces (#18)
Copilot suggestion for catch clause stack exception to retain raw errors.
1 parent 2aa6edc commit 511323f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/Console/SpectreConsoleReporter.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ internal static async Task<T> RunOperationAsync<T>(string description, Func<Canc
3737

3838
var escapedDescription = Markup.Escape(description);
3939
T? result = default;
40-
Exception? failure = null;
4140

4241
await Ansi.Progress()
4342
.Columns(new TaskDescriptionColumn(), new SpinnerColumn(), new ProgressBarColumn(), new PercentageColumn())
@@ -49,18 +48,13 @@ await Ansi.Progress()
4948
result = await operation(cancellationToken);
5049
task.Value = task.MaxValue;
5150
}
52-
catch (Exception ex)
51+
catch
5352
{
54-
failure = ex;
5553
task.StopTask();
54+
throw;
5655
}
5756
});
5857

59-
if (failure is not null)
60-
{
61-
throw failure;
62-
}
63-
6458
return result!;
6559
}
6660

0 commit comments

Comments
 (0)