question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blazor doesn't render ErrorBoundary's ErrorContent when there are two different exceptions inside it's ChildContent

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

ErrorBoundary renders nothing when there are two different errors inside it’s ChildContent.

Expected Behavior

ErrorBoundary renders exception information.

Steps To Reproduce

App.razor

<ErrorBoundary>
    <ChildContent>
        <ComponentWithError />
    </ChildContent>
    <ErrorContent>
        <div style="background: red">@context</div>
    </ErrorContent>
</ErrorBoundary>

ComponentWithError.razor

@{
    throw new Exception("error2");
}

@code
{
    protected override async Task OnInitializedAsync()
    {
        throw new Exception("error");
    }
}

Exceptions (if any)

No response

.NET Version

6.0.101

Anything else?

I originally ran into this problem when I misspelled the parameter name in the inner component of ComponentWithError: <ComponentWithoutProp BadProp=1 /> Which throws an exception by itself.

Also with exception inside void OnInitialized() everything works fine.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
xietycommented, Oct 26, 2022

And the following does not work:

    protected override async Task OnInitializedAsync()
    {
        await File.ReadAllTextAsync("NOT EXISTS");
    }

https://blazorrepl.telerik.com/mcbucUvh06LNyOkj40

1reaction
xietycommented, Oct 26, 2022

I tried to make a minimal reproducible example. Of course there is much more code to await in real use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor WASM ErrorBoundary is not catching missing ...
This seems to work OK for exceptions thrown from withing life-cycle methods. For an App.razor file like: <ErrorBoundary> <ErrorContent> Got you!
Read more >
Blazor "Error boundaries" design proposal · Issue #30940
The ErrorBoundary ancestor receives the HandleError call and responds by re-rendering itself. This time instead of rendering ChildContent , it ...
Read more >
Handle errors in ASP.NET Core Blazor apps
Error boundaries provide a convenient approach for handling exceptions. The ErrorBoundary component: Renders its child content when an error ...
Read more >
Unhandled Exceptions in Blazor Server with Error ...
Inside ErrorContent —which, for the record, is technically a RenderFragment<Exception> —displays when there's an unhandled error.
Read more >
The .NET Stacks #57: Taking a look at Blazor Error Boundaries
Blazor Error Boundaries is not meant to be a global exception handling mechanism for any and all unhandled errors you encounter in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found