Throw exception if connection to server fails