Better error handling for connections.