Synchronous Call Used for RadzenButton.Click

I am attempting to introduce exception handling for my Blazor application, and one thing that I noticed is that there seems to be a difference between exceptions encountered with RadzenButton.Click and that of RadzenTemplateForm.Submit.

After some digging, it appears that the RadzenButton.Click (or rather RadzenButton.OnClick) is called synchronously rather than asynchronously.

Turns out there is a difference in how Blazor handles these two approaches. Asynchronous calls are bubbled up to the Blazor's blazor-error-ui component and displayed to the user. Synchronous calls do not get promoted and essentially result in a silent error, and are not displayed to the user.

I wanted to bring this to the attention of the forum here and see if there is anything obvious I am not considering and/or if this is a know issue. Thank you for any context you can provide. :+1:

Can you provide some sample code which reproduces the problem you are experiencing? We will investigate and see if we can address it.

Sure thing @korchev here you go:

@page "/"

<h1>Hello, world!</h1>

Welcome to your new app.

<RadzenButton Click="OnClick" Text="No Message" /> | <button @onclick="OnClick">Pretty message</button>

@code
{
    Task OnClick(MouseEventArgs parameter)
    {
        throw new InvalidOperationException("Error");
    }
}

Again, this might be due to misunderstanding and learning Blazor, but the <button /> throws an exception and emits its details to the debug log, as well as showing a message to the user. At this point the circuit between server and client is broken and you have to refresh the page to re-establish it. This works according to what is described and expected in Blazor's exception handling documentation.

So, this button can only be clicked once and the page ceases to work.

With <RadzenButton />, however, you are able to click the button numerous times but no message is displayed to the user. Additionally, the following is emitted to the debug console in Visual Studio:

Exception thrown: 'System.InvalidOperationException' in RadzenButtonException.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.AspNetCore.Components.dll

Notice that there is no stack trace or message. There is no feedback that an exception has occurred and as a result is a deviance from the default behavior, as I understand it.

Please let me know if I have fundamentally misunderstood something here and/or you require any further information and I will do my best to get it to you. :+1: