How to display error details within blazor-error-ui element in Blazor WebAssembly?

Viewed 8687

For my Blazor WebAssembly app, I would like to be able to display details of the error (message, stacktrace) within the blazor-error-ui element.

How do I do this?

1 Answers

The trouble with the blazor-error-ui is they are on the HTML index page which is not a Blazor component.

As a workaround you could create your own Blazor component and use Cascading Values to display the errors. Please see link https://nightbaker.github.io/gitflow/azure/piplines/2020/01/22/blazor-error-component/

You would of course have to handle the errors with a try catch block and populate the error message and stack trace into your custom Blazor component.

Seems a lot of work when all you have to do is press F12 and view the same in the developer tools.

Related