I have an exception that has been generated in a certain context of my application.
I would like to be able to collect it, send it to the logger and recover the previous state.

The problem is that this error-bound exception cannot be accessed since its current exception property is protected.

What would be the solution?
I had the same problem and after investigating the source code it was easy to get the current exception from ErrorContent of the ErrorBoundary.
<ErrorBoundary>
<ChildContent>
@Body
</ChildContent>
<ErrorContent Context="Exception">
<div>
@Exception.Message<br/>
</div>
</ErrorContent>
</ErrorBoundary>
Get the current exception from the Context (RenderFragment) of ErrorContent (see above code example).
ErrorBoundaryBase ->
/// <summary>
/// The content to be displayed when there is an error.
/// </summary>
[Parameter] public RenderFragment<Exception>? ErrorContent { get; set; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With