HBASE-7268, I was going over the changes in RegionMovedException, and realized that, for some class of exceptions (RegionMoved, RegionOffline, etc), we have to carry some data over the wire to the client side which should be PB'ed as well. Right now, we are sending the stack trace over, and from the client side, parsing the stack trace. i guess this is not handled at the attached spec as well.
Thinking about the problem with Sergey and DD, we realized that there are mainly two classes of exceptions that we can throw. RegionMovedException, and the like are different from KeeperException, etc, in the sense that they are expected return values for some rpc calls, like put, and they carry data.
In the end, I think we have to be able to define PB messages for some exceptions:
required ServerName serverName = 1;
optional int64 openSeqNum = 2;
Now given that, I think we can do the enum approach of enumerating all exception messages in RpcException, and have the ipc layer from the client side construct the actual exception class with passing the Message to the exception c.tor. We can have a superclass like, PBException extends Exception containing a Message, and RegionMovedException extends PBException. The ipc layer from the server side, will know about PBException, and will pass the serialized bytes.
Alternatively, we can try to embed the exception that the client knows about (RegionMovedException) to the actual response messages, as valid messages. The region server code in this case for example, will not throw an exception, but instead, but the exception data in the response, and pass to rpc layer. The actual RPC response will be SUCCESS, not ERROR, but the client can inspect the response data, and see that exception (and maybe construct and throw an actual exception).