-
-
Notifications
You must be signed in to change notification settings - Fork 382
feat(ErrorLogger): redesign ErrorLogger component #7558
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ab9adbd
refactor: 更新日志逻辑
ArgoZhang b2a017a
test: 更新单元测试
ArgoZhang 5a3cd88
doc: 更新示例
ArgoZhang 5a70964
test: 更新单元测试
ArgoZhang 0a3a5a2
feat: 增加 ErrorRender 组件
ArgoZhang 200965b
doc: 文档格式化
ArgoZhang e9285f3
doc: 文档格式化
ArgoZhang 31179f3
Merge branch 'main' into fix-error
ArgoZhang 6eed865
refactor: 增加异常日志等逻辑
ArgoZhang 8086de2
test: 更新单元测试
ArgoZhang 292810a
Merge branch 'main' into fix-error
ArgoZhang 6aa5263
refactor: 增加 ToastTitle 本地化位置
ArgoZhang a9b66c4
doc: 更新注释
ArgoZhang 4edac12
feat: 增加日志开关逻辑
ArgoZhang 6d9319a
refactor: 重构异常处理机制
ArgoZhang 2939a4c
test: 更新单元测试
ArgoZhang 00c877a
refactor: 重构代码
ArgoZhang cdda94d
test: 排除单元测试
ArgoZhang 5a14521
doc: 更新示例
ArgoZhang aadd3ce
refactor: 重构代码
ArgoZhang 2669c1b
test: 更新单元测试
ArgoZhang 8ae2cc4
test: 支持弹窗显示错误信息
ArgoZhang cf01d37
test: 增加单元测试
ArgoZhang 4a45288
doc: 更新示例
ArgoZhang a74fc6d
doc: 增加排序
ArgoZhang de38fcd
chore: 重构代码
ArgoZhang 9ffadb5
doc: 更新注释
ArgoZhang d43af10
chore: bump version 10.2.2
ArgoZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/BootstrapBlazor.Server/Components/Samples/GlobalException.razor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
| // See the LICENSE file in the project root for more information. | ||
| // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone | ||
|
|
||
| using Microsoft.AspNetCore.Components.Rendering; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| namespace BootstrapBlazor.Components; | ||
|
|
||
| class ErrorRender : IComponent | ||
| { | ||
| [Inject] | ||
| [NotNull] | ||
| private IConfiguration? Configuration { get; set; } | ||
|
ArgoZhang marked this conversation as resolved.
|
||
|
|
||
| private RenderHandle _renderHandle; | ||
|
|
||
| void IComponent.Attach(RenderHandle renderHandle) | ||
| { | ||
| _renderHandle = renderHandle; | ||
| } | ||
|
|
||
| private Exception? _ex; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| /// <param name="parameters"></param> | ||
| /// <returns></returns> | ||
| /// <exception cref="NotImplementedException"></exception> | ||
| public Task SetParametersAsync(ParameterView parameters) | ||
| { | ||
| _ex = parameters.GetValueOrDefault<Exception>("Exception"); | ||
| _renderHandle.Render(BuildRenderTree); | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc/> | ||
| /// </summary> | ||
| /// <param name="builder"></param> | ||
| private void BuildRenderTree(RenderTreeBuilder builder) | ||
| { | ||
| if (_ex is not null) | ||
| { | ||
| builder.OpenElement(0, "div"); | ||
| builder.AddAttribute(1, "class", "error-stack"); | ||
| builder.AddContent(2, GetErrorContentMarkupString(_ex)); | ||
| builder.CloseElement(); | ||
| } | ||
| } | ||
|
|
||
| private bool? _errorDetails; | ||
| private MarkupString GetErrorContentMarkupString(Exception ex) | ||
| { | ||
| _errorDetails ??= Configuration.GetValue("DetailedErrors", false); | ||
| return _errorDetails is true | ||
| ? ex.FormatMarkupString(Configuration.GetEnvironmentInformation()) | ||
| : new MarkupString(ex.Message); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.