Made some tests myself and it seems that throwing the exception is the only
half-way good way right now. Returning null results in the status being
overwritten with "Cancelled". Another way that I found working but don't
really like is creating an instance using the Activator:
public override Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
TRequest request, ServerCallContext context, UnaryServerMethod<TRequest,
TResponse> continuation)
{
context.Status = new Status(StatusCode.Aborted, "Interceptor aborted");
return Task.FromResult(Activator.CreateInstance<TResponse>());
}
The problem is, that TRequest and TResponse are only restricted as class
and not as IMessage. If it would have been limited to "IMessage, new()" it
would have been easier to just use "new TResponse()".
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/2273f23f-142e-4d8a-9bee-f4b0174f7952%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.