Skip to content

Commit

Permalink
Don't swallow stacktrace from adapter exception when running in thread (
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd authored Feb 12, 2021
1 parent 35d6bf5 commit 6b625d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions
{
using System;
using System.Runtime.ExceptionServices;
using System.Threading;

using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
Expand Down Expand Up @@ -42,7 +43,8 @@ public void Run(Action action, PlatformApartmentState apartmentState, bool waitF
thread.Join();
if (exThrown != null)
{
throw exThrown;
// Preserve the stacktrace when re-throwing the exception.
ExceptionDispatchInfo.Capture(exThrown).Throw();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions
{
using System;
using System.Runtime.ExceptionServices;
using System.Threading;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;

Expand Down Expand Up @@ -45,7 +46,8 @@ public void Run(Action action, PlatformApartmentState apartmentState, bool waitF
thread.Join();
if (exThrown != null)
{
throw exThrown;
// Preserve the stacktrace when re-throwing the exception.
ExceptionDispatchInfo.Capture(exThrown).Throw();
}
}
}
Expand Down

0 comments on commit 6b625d4

Please sign in to comment.