Skip to content

Commit e050df2

Browse files
committed
fix: handle exceptions in the same way as DispatchEventAsync
1 parent 1e54b88 commit e050df2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/bunit.core/Rendering/TestRenderer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
184184
// if the event contains associated data.
185185
lock (renderTreeUpdateLock)
186186
{
187-
Dispatcher.InvokeAsync(() =>
187+
var result = Dispatcher.InvokeAsync(() =>
188188
{
189189
try
190190
{
@@ -196,7 +196,7 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
196196
}
197197
catch (TargetInvocationException ex) when (ex.InnerException is not null)
198198
{
199-
HandleException(ex.InnerException);
199+
throw ex.InnerException;
200200
}
201201
finally
202202
{
@@ -206,6 +206,11 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
206206
ProcessPendingRender();
207207
});
208208

209+
if (result.IsFaulted && result.Exception is not null)
210+
{
211+
HandleException(result.Exception);
212+
}
213+
209214
AssertNoUnhandledExceptions();
210215
}
211216
}

0 commit comments

Comments
 (0)