views:

119

answers:

1

Protocol Buffers doesn't have a native Exception type. What would a suitable .proto file for cross-language exceptions look like?

+2  A: 

The technical lead of Protocol Buffers, Kenton Varda, says in comment 9 on this blog post:

If you need to return structured errors, then the right way to do it is to make your response type be able to represent that information... We felt that supporting exceptions explicitly would add too much complication with little real gain.

This makes sense, given that if you want to return detailed error information, the .proto declarations would differ depending on the situation. If you want very generic exceptions (just a string message) then an underlying RPC mechanism may be able to provide this already, e.g. HTTP status.

Daniel Earwicker
Thanks, that was very useful. I'd read the post earlier before Kenton Varda's comment.It is now clear that I have to implement a cross-language exception model, I was hoping to leverage community cleverness on this one.The exceptions have to be detailed to be useful in a way that HTTP statuses aren't. The challenge is modeling exceptions that make sense in different language, e.g. how much sense does a Python 'StopIteration' make to C++/PHP/Java?
saidimu