Skip to content

Commit 967c6a1

Browse files
committed
fix: handle exceptions in the same way as DispatchEventAsync
1 parent d51a1b3 commit 967c6a1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/bunit.core/Rendering/TestRenderer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
194194
// if the event contains associated data.
195195
lock (renderTreeUpdateLock)
196196
{
197-
Dispatcher.InvokeAsync(() =>
197+
var result = Dispatcher.InvokeAsync(() =>
198198
{
199199
try
200200
{
@@ -206,7 +206,7 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
206206
}
207207
catch (TargetInvocationException ex) when (ex.InnerException is not null)
208208
{
209-
HandleException(ex.InnerException);
209+
throw ex.InnerException;
210210
}
211211
finally
212212
{
@@ -216,6 +216,11 @@ internal void SetDirectParameters(IRenderedFragmentBase renderedComponent, Param
216216
ProcessPendingRender();
217217
});
218218

219+
if (result.IsFaulted && result.Exception is not null)
220+
{
221+
HandleException(result.Exception);
222+
}
223+
219224
AssertNoUnhandledExceptions();
220225
}
221226
}

0 commit comments

Comments
 (0)