Skip to content

Commit 56b9907

Browse files
fix(ErrorLogger): add custom OnErrorHandleAsync on Layout not work (#6004)
* refactor: 增加 OnErrorHandleAsync 处理逻辑 * chore: bump version 9.6.2-beta01 Co-Authored-By: Jayce Liu <[email protected]> * Revert "refactor: 增加 OnErrorHandleAsync 处理逻辑" This reverts commit 75d4f36. * refactor: 增加自定义异常处理逻辑优先处理 * test: 更新单元测试 * refactor: 精简代码 --------- Co-authored-by: Jayce Liu <[email protected]>
1 parent 7d3ac79 commit 56b9907

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.6.1</Version>
4+
<Version>9.6.2-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/ErrorLogger/BootstrapBlazorErrorBoundary.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,8 @@ class BootstrapBlazorErrorBoundary : ErrorBoundaryBase
5353
/// <inheritdoc/>
5454
/// </summary>
5555
/// <param name="exception"></param>
56-
/// <returns></returns>
57-
/// <exception cref="NotImplementedException"></exception>
5856
protected override async Task OnErrorAsync(Exception exception)
5957
{
60-
// 由框架调用
61-
if (OnErrorHandleAsync != null)
62-
{
63-
await OnErrorHandleAsync(Logger, exception);
64-
return;
65-
}
66-
6758
if (ShowToast)
6859
{
6960
await ToastService.Error(ToastTitle, exception.Message);
@@ -124,6 +115,13 @@ private MarkupString GetErrorContentMarkupString(Exception ex)
124115
/// <param name="handler"></param>
125116
public async Task RenderException(Exception exception, IHandlerException? handler)
126117
{
118+
// 外部调用
119+
if (OnErrorHandleAsync != null)
120+
{
121+
await OnErrorHandleAsync(Logger, exception);
122+
return;
123+
}
124+
127125
if (handler != null)
128126
{
129127
await handler.HandlerException(exception, ExceptionContent);

test/UnitTest/Services/FullScreenServiceTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public async Task ButtonIcon_Ok()
1717
{
1818
builder.Add(s => s.Icon, "fa-solid fa-maximize");
1919
builder.Add(s => s.Text, "button-text");
20+
builder.Add(s => s.TargetId, "fsId");
2021
});
2122
cut.Contains("bb-fs-off");
2223
cut.Contains("bb-fs-on");

0 commit comments

Comments
 (0)