mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-11 19:02:15 +08:00
24 lines
634 B
C#
24 lines
634 B
C#
using Grpc.Core;
|
|
using Grpc.Core.Interceptors;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace BuildingBlocks.Exception;
|
|
|
|
public class GrpcExceptionInterceptor : Interceptor
|
|
{
|
|
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
|
|
TRequest request,
|
|
ServerCallContext context,
|
|
UnaryServerMethod<TRequest, TResponse> continuation)
|
|
{
|
|
try
|
|
{
|
|
return await continuation(request, context);
|
|
}
|
|
catch (System.Exception exception)
|
|
{
|
|
throw new RpcException(new Status(StatusCode.Internal, exception.Message));
|
|
}
|
|
}
|
|
}
|