Hi,

I had some questions about the api design of RpcError. From what I can tell 
in docs I should catch RpcError and switch on code (since it's also 
implicitly a `Call`). A few things frustrate me about this.

   1. There are certain codes I'd like to treat one way and certain codes 
   I'd like to treat another way. It seems slightly more pythonic to have one 
   exception class per code, especially given the number of codes is fixed and 
   the python client will treat any code that is not one of the known status 
   codes as "unknown". This would let me catch the specific codes I care about 
   by `excepting` only the classes that represent those codes, rather than 
   catching all RpcError, switching, and reraising otherwise.
   2. The api of `_Rendezvous` is pretty large, and we're told to count on 
   behavior that is implicitly there as a result of it being a `Call`, rather 
   that an api where we can catch an `GrpcException` that has a base api of 
   methods that are available and make sense to call on the exception. I'm not 
   sure which methods out of Call/Future make sense to call when I catch the 
   RpcError (that is actually a _Rendezvous). Right now I use `code` and 
   `details` and the `metadata`. I think changing this would also help toward 
   the goal of "Support static type-checking of both gRPC Python itself and of 
   code that uses gRPC Python" mentioned in the gsoc list. 
   <https://github.com/grpc/grpc/blob/master/summerofcode/ideas.md> 

In my opinion, it makes more sense that instead of the opaque RpcError, 
grpc python exposed a exception class per code that derived from a base 
class that actually had a meaningful set of methods to call (rather than 
inheriting most of the future methods that don't make sense for me to call 
on the error). I was wondering if I'm missing something about idiomatically 
handling errors on the client, and what went into the current design of the 
exception api.

Thanks,
Ashwin

-- 
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/8c49645c-6d43-43ef-98b6-aaff7cff0b7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to