fix connect error handling