Skip to content

Commit

Permalink
Merge pull request #8001 from abpframework/liangshiwei/abpremotecalle…
Browse files Browse the repository at this point in the history
…xception

Handle AbpRemoteCallException in DefaultExceptionToErrorInfoConverter
  • Loading branch information
hikalkan committed Mar 16, 2021
2 parents a995e66 + 363c64f commit 2a94795
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Components.Messages;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.DependencyInjection;
Expand All @@ -15,12 +16,16 @@ public class UserExceptionInformer : IUserExceptionInformer, ITransientDependenc
protected IUiMessageService MessageService { get; }
protected IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; }

protected AbpExceptionHandlingOptions Options { get; }

public UserExceptionInformer(
IUiMessageService messageService,
IExceptionToErrorInfoConverter exceptionToErrorInfoConverter)
IExceptionToErrorInfoConverter exceptionToErrorInfoConverter,
IOptions<AbpExceptionHandlingOptions> options)
{
MessageService = messageService;
ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter;
Options = options.Value;
Logger = NullLogger<UserExceptionInformer>.Instance;
}

Expand All @@ -41,12 +46,7 @@ public void Inform(UserExceptionInformerContext context)

protected virtual RemoteServiceErrorInfo GetErrorInfo(UserExceptionInformerContext context)
{
if (context.Exception is AbpRemoteCallException remoteCallException)
{
return remoteCallException.Error;
}

return ExceptionToErrorInfoConverter.Convert(context.Exception, false);
return ExceptionToErrorInfoConverter.Convert(context.Exception, Options.SendExceptionsDetailsToClients);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Volo.Abp.ExceptionHandling;
using Volo.Abp.ExceptionHandling.Localization;
using Volo.Abp.Http;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Validation;
Expand Down Expand Up @@ -62,6 +63,11 @@ protected virtual RemoteServiceErrorInfo CreateErrorInfoWithoutCode(Exception ex
return CreateEntityNotFoundError(exception as EntityNotFoundException);
}

if (exception is AbpRemoteCallException remoteCallException)
{
return remoteCallException.Error;
}

var errorInfo = new RemoteServiceErrorInfo();

if (exception is IUserFriendlyException)
Expand Down

0 comments on commit 2a94795

Please sign in to comment.