handle errors while connecting