Add some exception handling to connect method

This exception handling should be cleaned up and centralized, if
possible