Extracting connect failure handling into a separate method.