Skip to content
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

Handle AbpRemoteCallException in DefaultExceptionToErrorInfoConverter #8001

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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