[zeromq-dev] Zero MQ Wrapper APi language binding convention

Martin Sustrik sustrik at 250bpm.com
Tue Sep 27 14:24:33 CEST 2011


On 09/19/2011 11:02 AM, Patrick Marques wrote:

> I have another question about bindings, in the code style you write "C++
> exceptions are not to be used within the core codebase".

That applies to core library codebase. In the bindings it's up to you 
whether to use exceptions.

> I've asked to gonzus (Gonzalo Diethelm) on its java binding why don't
> use exceptions to give the "error" of unimplemented operations (on this
> thread https://github.com/zeromq/jzmq/issues/73).

Yes. The reason is historical rather than technical.

> What is your opinion about this? Exceptions are quite heavy but on this
> case for something that we expect nev	er occurs, specially on this case,
> where the operation are not supported (for instance, due to support
> version 2 and 3). Return -1 can give the ideia that this was working og
> worse int sets where nothing was done, (return forced, for instance
> https://github.com/zeromq/jzmq/blob/master/src/org/zeromq/ZMQ.java#L715)

I would say, stick with single event reporting mechanism. If you want to 
go for exceptions, great. However, make sure that all errors are 
reported via excpetions.

Mixing exceptions with returning error codes is very confusing for the user.

Martin



More information about the zeromq-dev mailing list