I try to use gRPC-web with angular client and asp.netCore server side app. in server side when I throw a RpcException I could not access to Metadata or even error message on client side? is there any thing, I miss to implement?
private static async Task<RpcException> HandleRpcExceptionAsync<T>(RpcException exception, CallContext context,
ILogger<T> logger,
ILocalizationService localizationService,
IWorkContext workContext,
Guid correlationId)
{
logger.LogError(exception, "CorrelationId: {CorrelationId} - An error occurred", correlationId);
var trailers = exception.Trailers;
trailers.Add(CreateTrailers(correlationId, exception.Message)[0]);
return new RpcException(new Status(exception.StatusCode, exception.Message, exception), trailers, exception.Message);
}
private static Metadata CreateTrailers(Guid correlationId,string errorMessage )
{
var trailers = new Metadata { { "CorrelationId", correlationId.ToString() }, {"errorMessage", "Test Farhad Error"} };
return trailers;
}
I try GrpcStatusEvent properties but allways I see GrpcMetadata with zero mapping (Map(0)), also try to add WithExposedHeaders("Grpc-Status", "Grpc-Message", "Grpc-Encoding", "Grpc- Accept-Encoding") but nothing happened