detecting connection error and showing an appropriate message