Protocol Buffers doesn't have a native Exception type. What would a suitable .proto file for cross-language exceptions look like?
Protocol buffers provide a language-neutral, platform-neutral, extensible mechanism for serializing structured data in a forward-compatible and backward-compatible way. It's like JSON, except it's smaller and faster, and it generates native language bindings.
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services. Google made this protocol open source and now it provides support, out of the box, to the most common languages, like JavaScript, Java, C#, Ruby and others.
Protobuf strings are always valid UTF-8 strings. See the Language Guide: A string must always contain UTF-8 encoded or 7-bit ASCII text.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With