Posts

Showing posts from May, 2022

Error Boundaries in Blazor

Image
This blog is going to explain what is Error Boundary in Blazor and how to implement it in the application. The Error Boundary is an easy way to handle the exception. If there is no error it will render the content, otherwise it will display the error message. Wrapping error Error Boundary component around the content will handle the unhandled exception. Let’s see this with an example. The following is the Index.razor page. Here I have added the Counter component covered by the <ErrorBoundary> component. Index.razor @page   "/"   < PageTitle > Index </ PageTitle >   < h1 > Hello, world! </ h1 >   Welcome to your new app.   < SurveyPrompt   Title = "How is Blazor working for you?"  />   < ErrorBoundary > < Counter  /> </ ErrorBoundary > To demonstrate the error handling process. I have modified the existing IncrementCount() as follows. So when the user clicks the click me button it