code: def connected(func):
      
      @wraps(func)
      def wrapper(*args, **kwargs):
          self = args[0]
          if not self.connected:
              self.show_output("Not connected.")
          else:
              try:
                  return func(*args, **kwargs)
              except APIError:
                  self.show_output("ZooKeeper internal error.")
              except AuthFailedError:
                  self.show_output("Authentication failed.")
              except NoAuthError:
                  self.show_output("Not authenticated.")
              except BadVersionError:
                  self.show_output("Bad version.")
              except ConnectionLoss:
                  self.show_output("Connection loss.")
              except NotReadOnlyCallError:
                  self.show_output("Not a read-only operation.")
              except BadArgumentsError:
                  self.show_output("Bad arguments.")
              except SessionExpiredError:
                  self.show_output("Session expired.")
              except UnimplementedError as ex:
                  self.show_output("Not implemented by the server: %s." % str(ex))
              except ZookeeperError as ex:
                  self.show_output("Unknown ZooKeeper error: %s" % str(ex))
  
      return wrapper
docs: check connected, fails otherwise