Browse Source

Merge pull request #22436 from abpframework/UserExceptionInformer

Don't write remote exceptions to console for Blazor WASM.
pull/22595/head
Halil İbrahim Kalkan 1 year ago
committed by GitHub
parent
commit
7f28d9bb47
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs
  2. 3
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs

15
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs

@ -8,6 +8,7 @@ using Volo.Abp.AspNetCore.Components.Messages;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http;
using Volo.Abp.Http.Client;
namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling;
@ -35,6 +36,8 @@ public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency
{
//TODO: Create sync versions of the MessageService APIs.
LogException(context);
var errorInfo = GetErrorInfo(context);
if (errorInfo.Details.IsNullOrEmpty())
@ -49,6 +52,8 @@ public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency
public async Task InformAsync(UserExceptionInformerContext context)
{
LogException(context);
var errorInfo = GetErrorInfo(context);
if (errorInfo.Details.IsNullOrEmpty())
@ -70,4 +75,14 @@ public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency
options.SendExceptionDataToClientTypes = Options.SendExceptionDataToClientTypes;
});
}
protected virtual void LogException(UserExceptionInformerContext context)
{
if (context.Exception is AbpRemoteCallException && OperatingSystem.IsBrowser())
{
return;
}
Logger.LogException(context.Exception);
}
}

3
framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs

@ -172,8 +172,7 @@ public abstract class AbpComponentBase : OwningComponentBase
{
return;
}
Logger.LogException(exception);
await InvokeAsync(async () =>
{
await UserExceptionInformer.InformAsync(new UserExceptionInformerContext(exception));

Loading…
Cancel
Save