Search code examples
blazorblazor-webassembly

Blazor does not throw a not implemented Exception


I have this simple event handler:

public void RowClicked(TableRowClickEventArgs<Prods> p)
{
    throw new NotImplementedException();            
}

that get called from this componenet :

<MudTable Items="@Products" OnRowClick="@RowClicked" >
</MudTable>

the problem is that blazor doesn't throw anything when the method is triggered, is this behavior normal?


Solution

  • In Answer to your question "is this behavior normal ?". No. (I've stated this directly as some reviewer yesterday stated (incorrectly) that what was posted didn't directly answer the question and therefore marked down it down!!!).

    Here's a very simplistic razor markup page to throw an error and show you what is normal:

    @page "/exceptionpage"
    
    <div class="m-3 p-3">
        <button class="btn btn-danger ml-2" @onclick="() => ThrowException()">Throw Exception</button>
    </div>
    
    @code {
        void ThrowException()
            => throw new NotImplementedException();
    }
    

    Which when it's run in Server mode in Debug throws the following Console Output

    The method or operation is not implemented.
    
    'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.5\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.5\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.5\System.Collections.Immutable.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.5\System.IO.MemoryMappedFiles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: The method or operation is not implemented.
    
    System.NotImplementedException: The method or operation is not implemented.
       at Blazor.Starter.Pages.Index.ThrowException() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 61
       at Blazor.Starter.Pages.Index.<BuildRenderTree>b__0_4() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 18
       at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T](MulticastDelegate delegate, T arg)
       at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
       at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)
    Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'oiyAzPmWxjSN4vTZ-FvyxNu299jz_TxRMituQ8soZC0'.
    
    System.NotImplementedException: The method or operation is not implemented.
       at Blazor.Starter.Pages.Index.ThrowException() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 61
       at Blazor.Starter.Pages.Index.<BuildRenderTree>b__0_4() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 18
       at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T](MulticastDelegate delegate, T arg)
       at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
       at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)