Added more appropriate excpetion handlers when connection to server fails