Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Error boundaries#30874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SteveSandersonMS merged 55 commits intomainfromstevesa/error-boundaries
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
55 commits
Select commitHold shift + click to select a range
c0d3d59
Initial experiments
SteveSandersonMSMar 12, 2021
952cac0
Handle async event handler exceptions
SteveSandersonMSMar 12, 2021
4b12fc2
Test cases for lifecycle methods
SteveSandersonMSMar 12, 2021
cc44e53
Handle SetParametersAsync exceptions
SteveSandersonMSMar 12, 2021
5351089
Handle IHandleAfterRender exceptions
SteveSandersonMSMar 12, 2021
4e7e3c5
Handle exceptions during rendering
SteveSandersonMSMar 12, 2021
e6c1c1c
Update notes about disposal
SteveSandersonMSMar 12, 2021
0d6acd7
Add note about Attach
SteveSandersonMSMar 12, 2021
2b35fe8
Handle exceptions during cascading value notifications
SteveSandersonMSMar 12, 2021
42d1911
Update ErrorMaker.razor
SteveSandersonMSMar 12, 2021
2f68770
Add note about InvokeAsync
SteveSandersonMSMar 12, 2021
80ebf30
Clean up some notes
SteveSandersonMSMar 12, 2021
83de667
Clarify what we do if the IErrorBoundary component itself has an error
SteveSandersonMSMar 12, 2021
2a5a7d3
Force error boundaries to clear up their descendants on error, even b…
SteveSandersonMSMar 12, 2021
0cd43ff
More thoughts on error loops
SteveSandersonMSMar 12, 2021
0a7a07f
More thoughts
SteveSandersonMSMar 12, 2021
8089c36
Clean up all the stuff about detailed errors and prerendering
SteveSandersonMSMar 15, 2021
4514899
Add PrerenderingErrorBoundaryLogger
SteveSandersonMSMar 15, 2021
2de4259
Let error boundaries catch their own inline errors
SteveSandersonMSMar 16, 2021
415d8dd
Redesign around ErrorBoundaryBase abstract base class.
SteveSandersonMSMar 16, 2021
9529163
Define IErrorBoundary as an internal interface for clarity
SteveSandersonMSMar 17, 2021
bf04cf3
Minor fix
SteveSandersonMSMar 18, 2021
1db319e
Handle logging errors
SteveSandersonMSApr 6, 2021
0415115
Make it possible to customize the UI via subclassing ErrorBoundary
SteveSandersonMSApr 6, 2021
a28c3ca
Better default UI
SteveSandersonMSApr 6, 2021
275ae5a
Show you can subclass ErrorBoundary helpfully
SteveSandersonMSApr 6, 2021
d319b9f
Rename AutoReset->AutoRecover
SteveSandersonMSApr 6, 2021
15ab863
Remove use of linq
SteveSandersonMSApr 6, 2021
990128e
Tidy up comments
SteveSandersonMSApr 6, 2021
c9c7c6f
Clean up and expand test cases
SteveSandersonMSApr 6, 2021
2f597f4
CR: Add general-purpose OnErrorAsync to base class
SteveSandersonMSApr 6, 2021
29e4760
Remove AutoRecover feature because it can be done in user code now we…
SteveSandersonMSApr 6, 2021
08d4595
Unit tests for component error boundary dispatch logic
SteveSandersonMSApr 6, 2021
7540d3a
Make async flow clearer
SteveSandersonMSApr 6, 2021
34e6519
Fix unrelated test code badness
SteveSandersonMSApr 6, 2021
06da1ef
Add E2E test UI
SteveSandersonMSApr 6, 2021
259f5d5
Begin scripting E2E cases
SteveSandersonMSApr 6, 2021
63d950b
Add some E2E tests for more difficult cases
SteveSandersonMSApr 7, 2021
ae4cdc4
Cope with receiving errors while already in an error state
SteveSandersonMSApr 7, 2021
76f41fe
Add failing unit test for errors after disposal
SteveSandersonMSApr 7, 2021
f5be9f1
Have renderer cope with errors after disposal
SteveSandersonMSApr 7, 2021
31def59
Better handling of error loops
SteveSandersonMSApr 7, 2021
015b4e2
Fix description
SteveSandersonMSApr 7, 2021
832f72a
Tidyup
SteveSandersonMSApr 7, 2021
50c9ddb
Revert some unwanted changes
SteveSandersonMSApr 7, 2021
7df7d5a
More cleanup
SteveSandersonMSApr 7, 2021
0a61aaa
Add default error boundary content/style to project templates
SteveSandersonMSApr 7, 2021
4955cc3
Fix server E2E tests
SteveSandersonMSApr 7, 2021
92e506b
Test for custom error boundary
SteveSandersonMSApr 7, 2021
8f18c40
Test for error ignorer
SteveSandersonMSApr 7, 2021
d151976
Test for inline errors
SteveSandersonMSApr 7, 2021
d85c8d2
Test for errors after disposal
SteveSandersonMSApr 7, 2021
00e5e50
Test for multiple concurrent errors
SteveSandersonMSApr 7, 2021
5eae0b1
Stronger guidance to override OnErrorAsync
SteveSandersonMSApr 7, 2021
9ace45d
CR: Improve unit test
SteveSandersonMSApr 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Let error boundaries catch their own inline errors
  • Loading branch information
@SteveSandersonMS
SteveSandersonMS committedApr 6, 2021
commit2de42595dcf3352f44106c7405beadc38a6e8850
5 changes: 1 addition & 4 deletionssrc/Components/Components/src/RenderTree/Renderer.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -391,10 +391,7 @@ private bool TrySendExceptionToErrorBoundary(IComponent? errorSource, Exception
// If it becomes problematic, we can maintain a lookup from component instance to ID.
var componentState = _componentStateById.FirstOrDefault(kvp => kvp.Value.Component == errorSource).Value;

// Find the closest IErrorBoundary, if any. Start looking at the first parent, to ensure
// that an error boundary component doesn't try to handle its own errors, as that could
// be an infinite loop.
componentState = componentState?.ParentComponentState;
// Find the closest IErrorBoundary, if any
while (componentState is not null)
{
if (componentState.Component is IErrorBoundary errorBoundary)
Expand Down
18 changes: 18 additions & 0 deletionssrc/Components/Samples/BlazorServerApp/Pages/ErrorMaker.razor
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,6 +45,22 @@
<ErrorCausingCounter />
</ErrorIgnorer>
</fieldset>

<fieldset>
<legend>Exception inline in error boundary markup</legend>
<ErrorBoundary>
<ChildContent>
@if (throwInline) { throw new InvalidTimeZoneException("Inline exception"); }
<p>Hello!</p>
</ChildContent>
<ErrorContent>
@if (throwInErrorContent) { throw new InvalidTimeZoneException("Inline exception in error content"); }
<p>There was an error: @context</p>
</ErrorContent>
</ErrorBoundary>
<button @onclick="@(() => throwInline = true)">Throw in child content</button>
<button @onclick="@(() => throwInErrorContent = true)">Throw in error content</button>
</fieldset>
</fieldset>

@code {
Expand DownExpand Up@@ -98,6 +114,8 @@
private bool throwInOnAfterRender;
private bool throwInOnAfterRenderAsync;
private bool throwWhileRendering;
private bool throwInline;
private bool throwInErrorContent;

void EventHandlerErrorSync()
=> throw new InvalidTimeZoneException("Synchronous error from event handler");
Expand Down
8 changes: 8 additions & 0 deletionssrc/Components/Web/src/Web/ErrorBoundary.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Rendering;

Expand All@@ -26,6 +27,13 @@ public sealed class ErrorBoundary : ComponentBase, IErrorBoundary

public void HandleException(Exception exception)
{
if (_currentException is not null)
{
// If there's an error while we're already displaying error content, then it's the
// error content that's failing. Avoid the risk of an infinite error rendering loop.
ExceptionDispatchInfo.Capture(exception).Throw();
}

_ = ErrorBoundaryLogger!.LogErrorAsync(exception, clientOnly: false);

_currentException = exception;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp