Improve exception handling when connecting to cluster.