Handle exception thrown by gethostbyname