Fix startup failure on invalid games.yml

Add some exception checking/ignoring.
This commit is contained in:
Nekotekina 2020-02-15 22:28:35 +03:00
parent ee54ba970a
commit 634c4355fe

View File

@ -532,7 +532,33 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
add_dir(_hdd + "game/", false);
add_dir(_hdd + "disc/", true);
for (auto pair : YAML::Load(fs::file{fs::get_config_dir() + "/games.yml", fs::read + fs::create}.to_string()))
auto get_games = []() -> YAML::Node
{
try
{
fs::file games(fs::get_config_dir() + "/games.yml", fs::read + fs::create);
if (games)
{
return YAML::Load(games.to_string());
}
else
{
game_list_log.error("Failed to load games.yml, check permissions.");
return {};
}
}
catch (...)
{
// YAML exception aren't very useful so just ignore them
game_list_log.fatal("Failed to parse games.yml");
return {};
}
return {};
};
for (auto&& pair : get_games())
{
std::string game_dir = pair.second.Scalar();