Henry Robinson commented on ZOOKEEPER-510:

(Just got back from a long vacation, hence apologies for being slow to pick 
this up!)

Yes, this is bad. zkpython needs to mirror the set of Java exceptions as 
closely as possible, and it shouldn't be hard to do. 

There are some special cases for when exceptions should be raised - checking 
for ret != ZOK doesn't always work. I'm thinking of exists, which (in 
ZooKeeper) special cases NONODE and returns null instead of a KeeperException. 
This seems sensible to me - just wanted to explicitly acknowledge that I'm 
using ZooKeeper.java as the reference for how a client API should behave since 
the API docs are vague on exactly when an exception is raised.

> zkpython lumps all exceptions as IOError, needs specialized exceptions for 
> KeeperException types
> ------------------------------------------------------------------------------------------------
>                 Key: ZOOKEEPER-510
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-510
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: contrib-bindings
>    Affects Versions: 3.2.0
>            Reporter: Patrick Hunt
>            Assignee: Henry Robinson
>             Fix For: 3.3.0
> The current zkpython bindings always throw "IOError("text")" exceptions, even 
> for ZK specific exceptions such as NODEEXISTS. This makes it difficult (error 
> prone) to handle exceptions in python code. You can't easily pickup a 
> connection loss vs a node exists for example. Of course you could match the 
> error string, but this seems like a bad idea imo.
> We need to add specific exception types to the python binding that map 
> directly to KeeperException/java types. It would also be useful to include 
> the information provided by the KeeperException (like path in some cases), 
> etc... as part of the error thrown to the python code. Would probably be a 
> good idea to stay as close to java api as possible wrt mapping the errors.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

Reply via email to