Throwing the exception is the solution I'm using currently, however I was
previously advised that I can avoid that by setting the status and
returning: https://groups.google.com/forum/#!topic/grpc-io/OXKLky8p9f8
Thank you for your tests, it's odd that the status is overwritten with
"Cancelled". I know the C# Interceptors API is still fairly new, so I hope
we'll see some changes to this functionality.
On Monday, May 14, 2018 at 12:55:57 PM UTC+1, Benjamin Krämer wrote:
>
> 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/049dc193-6b99-4fe1-9825-ed2bb9e43935%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.