Move exceptional case to top of method.  Return null if connection could not be made.