Handle exceptions at loading patch file

This commit is contained in:
Nekotekina 2018-01-30 00:26:22 +03:00
parent 17ce5d9117
commit d66e56392e
1 changed files with 13 additions and 3 deletions

View File

@ -32,13 +32,23 @@ void patch_engine::append(const std::string& patch)
{ {
if (fs::file f{patch}) if (fs::file f{patch})
{ {
auto root = YAML::Load(f.to_string()); YAML::Node root;
try
{
root = YAML::Load(f.to_string());
}
catch (const std::exception& e)
{
LOG_FATAL(GENERAL, "Failed to load patch file %s\n%s thrown: %s", patch, typeid(e).name(), e.what());
return;
}
for (auto pair : root) for (auto pair : root)
{ {
auto& name = pair.first.Scalar(); auto& name = pair.first.Scalar();
auto& data = m_map[name]; auto& data = m_map[name];
for (auto patch : pair.second) for (auto patch : pair.second)
{ {
u64 type64 = 0; u64 type64 = 0;
@ -91,7 +101,7 @@ void patch_engine::append(const std::string& patch)
break; break;
} }
} }
data.emplace_back(info); data.emplace_back(info);
} }
} }