Well, note that if you compile with -DNDEBUG, the abort won't happen. We have a no-exception policy in C++, so I don't think we can replace this with an exception. Is -DNDEBUG good enough for you or do you want to look for another solution?
On Mon, Mar 23, 2009 at 2:32 PM, Dave Bailey <d...@daveb.net> wrote: > > Hi, > > libprotobuf calls abort() if one attempts to serialize a message that > is missing a required field. > > To me, this seems excessive, because it gives the calling code no > opportunity to handle the error in a different way. > > Here is the bug report in protobuf-perlxs: > > http://code.google.com/p/protobuf-perlxs/issues/detail?id=5 > > I have to do a lot of gymnastics to "catch" an abort(). Is it > possible to have libprotobuf throw an exception instead, or at least > give protoc (via an option of some sort) the ability to generate code > that would cause libprotobuf throw an exception if the caller tries to > serialize a message with a missing required field? > > This would make it possible to use the traditional Perl method of > trapping fatal errors (eval {}). > > A similar issue will probably arise in Python if a Python binding is > developed that generates a Python wrapper around C++ code. Python > programmers will expect a Python exception for an error like this, not > the termination of the program. > > -dave > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---