def observing_connection(&block)
      yield

    rescue *connection_errors => exception
      if defined?(Trouble)
        if Trouble.respond_to? :log  # Requires Trouble > 0.0.11
          Trouble.log exception, code: :lost_connection, message: 'Raidis lost connection to the Redis server.', client: redis.inspect
        else
          Trouble.notify exception, code: :lost_connection, message: 'Raidis lost connection to the Redis server.', client: redis.inspect
        end
      end

      raise Raidis::ConnectionError, exception

    rescue Redis::CommandError => exception
      if exception.message.to_s.split.first == 'READONLY'
        Trouble.notify(exception, code: :readonly, message: 'Raidis detected an illegal write against a Redis slave.', client: redis.inspect) if defined?(Trouble)
        raise Raidis::ConnectionError, exception
      else
        # Passing through Exceptions unrelated to the Connection. E.g. Redis::CommandError.
        raise exception
      end
    end
def observing_connection(&block)
      yield

    rescue *connection_errors => exception
      if defined?(Trouble)
        if Trouble.respond_to? :log  # Requires Trouble > 0.0.11
          Trouble.log exception, code: :lost_connection, message: 'Raidis lost connection to the Redis server.', client: redis.inspect
        else
          Trouble.notify exception, code: :lost_connection, message: 'Raidis lost connection to the Redis server.', client: redis.inspect
        end
      end

      raise Raidis::ConnectionError, exception

    rescue Redis::CommandError => exception
      if exception.message.to_s.split.first == 'READONLY'
        Trouble.notify(exception, code: :readonly, message: 'Raidis detected an illegal write against a Redis slave.', client: redis.inspect) if defined?(Trouble)
        raise Raidis::ConnectionError, exception
      else
        # Passing through Exceptions unrelated to the Connection. E.g. Redis::CommandError.
        raise exception
      end
    end
Internal: Raises a Raidis::ConnectionError if there are connection-related problems during the execution of the block.
 More specifically, if the connection is lost or a write is performed against a slave, the Exception will be raised.