From the course: Blazor WebAssembly: Foundational Skills

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Error handling

Error handling

- [Instructor] When using the Visual Studio template to create a Blazor WebAssembly app, a div tag is created in the index.html file. This is used to display errors that occur within the application. By default, this tag is not displayed when the app is running. It is only shown when there is a problem with it. However, as this tag appears outside the main Blazor WebAssembly app, it only displays a generic error message. To find out more details about the error, open up Developer Tools and the Console tab gives more detail about the error. In .NET 6, Blazor added the ErrorBoundary component as one of its new features. The ErrorBoundary can be wrapped around the existing content, like a Razor component. When this happens, it renders the child content as normal. However, it is able to render an error message when an unhandled exception is thrown. At the moment, adding a product to the Cart is throwing an error. The…

Contents