Skip to content

Commit 2a5fa08

Browse files
committed
Merge in 'release/6.0' changes
2 parents 27188b2 + 49066d9 commit 2a5fa08

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/Components/WebView/WebView/src/ComponentsWebViewServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.AspNetCore.Components;
55
using Microsoft.AspNetCore.Components.Routing;
6+
using Microsoft.AspNetCore.Components.Web;
67
using Microsoft.AspNetCore.Components.WebView.Services;
78
using Microsoft.Extensions.DependencyInjection.Extensions;
89
using Microsoft.JSInterop;
@@ -25,6 +26,7 @@ public static IServiceCollection AddBlazorWebView(this IServiceCollection servic
2526
services.TryAddScoped<IJSRuntime, WebViewJSRuntime>();
2627
services.TryAddScoped<INavigationInterception, WebViewNavigationInterception>();
2728
services.TryAddScoped<NavigationManager, WebViewNavigationManager>();
29+
services.TryAddScoped<IErrorBoundaryLogger, WebViewErrorBoundaryLogger>();
2830
return services;
2931
}
3032
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Components.Web;
5+
using Microsoft.Extensions.Logging;
6+
7+
namespace Microsoft.AspNetCore.Components.WebView.Services;
8+
9+
internal sealed class WebViewErrorBoundaryLogger : IErrorBoundaryLogger
10+
{
11+
private readonly ILogger<ErrorBoundary> _errorBoundaryLogger;
12+
13+
public WebViewErrorBoundaryLogger(ILogger<ErrorBoundary> errorBoundaryLogger)
14+
{
15+
_errorBoundaryLogger = errorBoundaryLogger;
16+
}
17+
18+
public ValueTask LogErrorAsync(Exception exception)
19+
{
20+
// For, client-side code, all internal state is visible to the end user. We can just
21+
// log directly to the console.
22+
_errorBoundaryLogger.LogError(exception, exception.ToString());
23+
return ValueTask.CompletedTask;
24+
}
25+
}

0 commit comments

Comments
 (0)