public static KeeperException create(Code code) {
        switch (code) {
        case SYSTEMERROR:
            return new SystemErrorException();
        case RUNTIMEINCONSISTENCY:
            return new RuntimeInconsistencyException();
        case DATAINCONSISTENCY:
            return new DataInconsistencyException();
        case CONNECTIONLOSS:
            return new ConnectionLossException();
        case MARSHALLINGERROR:
            return new MarshallingErrorException();
        case UNIMPLEMENTED:
            return new UnimplementedException();
        case OPERATIONTIMEOUT:
            return new OperationTimeoutException();
        case BADARGUMENTS:
            return new BadArgumentsException();
        case APIERROR:
            return new APIErrorException();
        case NONODE:
            return new NoNodeException();
        case NOAUTH:
            return new NoAuthException();
        case BADVERSION:
            return new BadVersionException();
        case NOCHILDRENFOREPHEMERALS:
            return new NoChildrenForEphemeralsException();
        case NODEEXISTS:
            return new NodeExistsException();
        case INVALIDACL:
            return new InvalidACLException();
        case AUTHFAILED:
            return new AuthFailedException();
        case NOTEMPTY:
            return new NotEmptyException();
        case SESSIONEXPIRED:
            return new SessionExpiredException();
        case INVALIDCALLBACK:
            return new InvalidCallbackException();
        case SESSIONMOVED:
            return new SessionMovedException();

        case OK:
        default:
            throw new IllegalArgumentException("Invalid exception code");
        }
    }
public static KeeperException create ( Code code ) { switch ( code ) { case SYSTEMERROR : return new SystemErrorException ( ) ; case RUNTIMEINCONSISTENCY : return new RuntimeInconsistencyException ( ) ; case DATAINCONSISTENCY : return new DataInconsistencyException ( ) ; case CONNECTIONLOSS : return new ConnectionLossException ( ) ; case MARSHALLINGERROR : return new MarshallingErrorException ( ) ; case UNIMPLEMENTED : return new UnimplementedException ( ) ; case OPERATIONTIMEOUT : return new OperationTimeoutException ( ) ; case BADARGUMENTS : return new BadArgumentsException ( ) ; case APIERROR : return new APIErrorException ( ) ; case NONODE : return new NoNodeException ( ) ; case NOAUTH : return new NoAuthException ( ) ; case BADVERSION : return new BadVersionException ( ) ; case NOCHILDRENFOREPHEMERALS : return new NoChildrenForEphemeralsException ( ) ; case NODEEXISTS : return new NodeExistsException ( ) ; case INVALIDACL : return new InvalidACLException ( ) ; case AUTHFAILED : return new AuthFailedException ( ) ; case NOTEMPTY : return new NotEmptyException ( ) ; case SESSIONEXPIRED : return new SessionExpiredException ( ) ; case INVALIDCALLBACK : return new InvalidCallbackException ( ) ; case SESSIONMOVED : return new SessionMovedException ( ) ; case OK : default : throw new IllegalArgumentException ( "Invalid exception code" ) ; } }
All non-specific keeper exceptions should be constructed via this factory
method in order to guarantee consistency in error codes and such. If you
know the error code, then you should construct the special purpose
exception directly. That will allow you to have the most specific
possible declarations of what exceptions might actually be thrown.

@param code
The error code of your new exception. This will also determine
the specific type of the exception that is returned.
@return The specialized exception, presumably to be thrown by the caller.