Improve error handling logic when running hostfile for enterprise