Browse Source

Merge pull request #8001 from abpframework/liangshiwei/abpremotecallexception

Handle AbpRemoteCallException in DefaultExceptionToErrorInfoConverter
pull/8081/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
2a94795fe8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ExceptionHandling/UserExceptionInformer.cs
  2. 0
      framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingOptions.cs
  3. 6
      framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs
  4. 0
      framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/Client/AbpRemoteCallException.cs

14
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ExceptionHandling/UserExceptionInformer.cs

@ -1,6 +1,7 @@
using System; using System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Components.Messages; using Volo.Abp.AspNetCore.Components.Messages;
using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
@ -15,12 +16,16 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.ExceptionHandling
protected IUiMessageService MessageService { get; } protected IUiMessageService MessageService { get; }
protected IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; } protected IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; }
protected AbpExceptionHandlingOptions Options { get; }
public UserExceptionInformer( public UserExceptionInformer(
IUiMessageService messageService, IUiMessageService messageService,
IExceptionToErrorInfoConverter exceptionToErrorInfoConverter) IExceptionToErrorInfoConverter exceptionToErrorInfoConverter,
IOptions<AbpExceptionHandlingOptions> options)
{ {
MessageService = messageService; MessageService = messageService;
ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter; ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter;
Options = options.Value;
Logger = NullLogger<UserExceptionInformer>.Instance; Logger = NullLogger<UserExceptionInformer>.Instance;
} }
@ -41,12 +46,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.ExceptionHandling
protected virtual RemoteServiceErrorInfo GetErrorInfo(UserExceptionInformerContext context) protected virtual RemoteServiceErrorInfo GetErrorInfo(UserExceptionInformerContext context)
{ {
if (context.Exception is AbpRemoteCallException remoteCallException) return ExceptionToErrorInfoConverter.Convert(context.Exception, Options.SendExceptionsDetailsToClients);
{
return remoteCallException.Error;
}
return ExceptionToErrorInfoConverter.Convert(context.Exception, false);
} }
} }
} }

0
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingOptions.cs → framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingOptions.cs

6
framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs

@ -11,6 +11,7 @@ using Volo.Abp.Domain.Entities;
using Volo.Abp.ExceptionHandling; using Volo.Abp.ExceptionHandling;
using Volo.Abp.ExceptionHandling.Localization; using Volo.Abp.ExceptionHandling.Localization;
using Volo.Abp.Http; using Volo.Abp.Http;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -62,6 +63,11 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
return CreateEntityNotFoundError(exception as EntityNotFoundException); return CreateEntityNotFoundError(exception as EntityNotFoundException);
} }
if (exception is AbpRemoteCallException remoteCallException)
{
return remoteCallException.Error;
}
var errorInfo = new RemoteServiceErrorInfo(); var errorInfo = new RemoteServiceErrorInfo();
if (exception is IUserFriendlyException) if (exception is IUserFriendlyException)

0
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpRemoteCallException.cs → framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/Client/AbpRemoteCallException.cs

Loading…
Cancel
Save