Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Google's Protocol Buffers, what is a suitable protocol file/model for Exceptions?

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

like image 745
saidimu apale Avatar asked Mar 28 '10 07:03

saidimu apale


People also ask

What are Google protocol buffers used for?

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.

What is the protocol of Google?

Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.

What is Protobuf format?

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.

What encoding does Protobuf use?

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.


1 Answers

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.

like image 187
Daniel Earwicker Avatar answered Sep 22 '22 03:09

Daniel Earwicker