With grpc 0.15.0 some time ago I implemented client side exception handler via spring aspect. It converts StatusRuntimeException from the upstream service into my own domain exception and re-throws it. I find it quite convenient as throughout the code I can catch particular exceptions I'm interested in instead of always catching StatusRuntimeException.
I consider switching to the latest (1.6.1) version, and the problem is that client stubs have been made final and it is no longer possible to use aspects.
The only (and ugly) solution is to do exception conversion in cancel method of SimpleForwardingClientCall(called from catch block in blockingUnaryCall). But in my understanding cancel method is not supposed to throw exceptions, especially in case when cancel is called by the client code itself.
For server-streaming calls it is not possible to catch-and-rethrow the exception thrown from iterator at all. With 0.15.0 I wrap returned iterator and override hasNext method to catch and re-throw the exception.
Has anyone tried to solve the same problem?
Maybe there are plans to include support for such cases in grpc?
Thank you in advance.