mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-30 00:07:47 +00:00
chore: pass ZoneLoading error as result
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
#include "ZoneLoading.h"
|
||||
|
||||
std::optional<Zone*> FastFileContext::LoadFastFile(const std::string& path)
|
||||
result::Expected<Zone*, std::string> FastFileContext::LoadFastFile(const std::string& path)
|
||||
{
|
||||
auto zone = ZoneLoading::LoadZone(path);
|
||||
if (!zone)
|
||||
return std::nullopt;
|
||||
return result::Unexpected(std::move(zone.error()));
|
||||
|
||||
return m_loaded_zones.emplace_back(std::move(zone)).get();
|
||||
return m_loaded_zones.emplace_back(std::move(*zone)).get();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/Result.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
class FastFileContext
|
||||
{
|
||||
public:
|
||||
std::optional<Zone*> LoadFastFile(const std::string& path);
|
||||
result::Expected<Zone*, std::string> LoadFastFile(const std::string& path);
|
||||
|
||||
std::vector<std::unique_ptr<Zone>> m_loaded_zones;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace
|
||||
ModManContext::Get().m_db_thread.Dispatch(
|
||||
[&wv, id, path]
|
||||
{
|
||||
const auto maybeZone = ModManContext::Get().m_fast_file.LoadFastFile(path);
|
||||
auto maybeZone = ModManContext::Get().m_fast_file.LoadFastFile(path);
|
||||
|
||||
if (maybeZone)
|
||||
{
|
||||
@@ -19,8 +19,8 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
con::warn("Failed to load zone \"{}\"", path);
|
||||
ui::PromiseReject(wv, id, false);
|
||||
con::warn("Failed to load zone \"{}\": {}", path, maybeZone.error());
|
||||
ui::PromiseReject(wv, id, std::move(maybeZone).error());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user