Browse Source

Delete GrpcExceptionInterceptor.cs

pull/75/head
Galip Tolga Erdem 5 years ago
parent
commit
f859fc80e5
  1. 42
      services/basket/src/EShopOnAbp.BasketService.Application/Grpc/GrpcExceptionInterceptor.cs

42
services/basket/src/EShopOnAbp.BasketService.Application/Grpc/GrpcExceptionInterceptor.cs

@ -1,42 +0,0 @@
using System.Threading.Tasks;
using Grpc.Core;
using Grpc.Core.Interceptors;
using Microsoft.Extensions.Logging;
using Volo.Abp.DependencyInjection;
namespace EShopOnAbp.BasketService.Grpc;
public class GrpcExceptionInterceptor : Interceptor, ITransientDependency
{
private readonly ILogger<GrpcExceptionInterceptor> _logger;
public GrpcExceptionInterceptor(ILogger<GrpcExceptionInterceptor> logger)
{
_logger = logger;
}
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(
TRequest request,
ClientInterceptorContext<TRequest, TResponse> context,
AsyncUnaryCallContinuation<TRequest, TResponse> continuation)
{
var call = continuation(request, context);
return new AsyncUnaryCall<TResponse>(HandleResponse(call.ResponseAsync), call.ResponseHeadersAsync,
call.GetStatus, call.GetTrailers, call.Dispose);
}
private async Task<TResponse> HandleResponse<TResponse>(Task<TResponse> task)
{
try
{
var response = await task;
return response;
}
catch (RpcException e)
{
_logger.LogError("Error calling via grpc: {Status} - {Message}", e.Status, e.Message);
return default;
}
}
}
Loading…
Cancel
Save