Added exception handling to getHomeDir()