Adding more exception handling for failed connections.