2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-10-24 07:15:51 +00:00

chore: add error handling for fastfile bind

This commit is contained in:
Jan Laupetin
2025-10-11 14:42:52 +01:00
parent 2037cf3258
commit 098be53559
4 changed files with 36 additions and 14 deletions

View File

@@ -5,8 +5,26 @@
namespace
{
void LoadFastFile(webview::webview& wv, std::string id, std::string path) // NOLINT(performance-unnecessary-value-param) Copy is made for thread safety
{
ModManContext::Get().m_db_thread.Dispatch(
[&wv, id, path]
{
const auto maybeZone = ModManContext::Get().m_fast_file.LoadFastFile(path);
}
if (maybeZone)
{
ui::PromiseResolve(wv, id, true);
con::debug("Loaded zone \"{}\"", maybeZone.value()->m_name);
}
else
{
con::warn("Failed to load zone \"{}\"", path);
ui::PromiseReject(wv, id, false);
}
});
}
} // namespace
namespace ui
{
@@ -16,13 +34,7 @@ namespace ui
"loadFastFile",
[&wv](const std::string& id, std::string path)
{
std::string idMove(id);
ModManContext::Get().m_db_thread.Dispatch(
[&wv, idMove, path]
{
ModManContext::Get().m_fast_file.LoadFastFile(path);
PromiseResolve(wv, idMove, true);
});
LoadFastFile(wv, id, std::move(path));
});
}
} // namespace ui