From 6ef462adccfc2ee3f172fa22b2ca9ab833374751 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 23 Jan 2025 00:11:15 -0600 Subject: [PATCH] [keel] Add clearer Error handling --- src/olympic/keel/include/keel/media.hpp | 7 +++++-- src/olympic/keel/src/media.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/olympic/keel/include/keel/media.hpp b/src/olympic/keel/include/keel/media.hpp index 069e202b..228bab75 100644 --- a/src/olympic/keel/include/keel/media.hpp +++ b/src/olympic/keel/include/keel/media.hpp @@ -63,8 +63,11 @@ namespace detail { template constexpr auto makeLoader(Context &ctx) { return [&ctx](ox::StringViewCR assetId) -> ox::Result { - OX_REQUIRE(p, ctx.uuidToPath.at(assetId)); - OX_REQUIRE(buff, ctx.rom->read(*p)); + auto const p = ctx.uuidToPath.at(assetId); + if (p.error) { + return ox::Error{1, "Asset ID not found"}; + } + OX_REQUIRE(buff, ctx.rom->read(*p.value)); auto [obj, err] = readAsset(buff); if (err) { if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) { diff --git a/src/olympic/keel/src/media.cpp b/src/olympic/keel/src/media.cpp index e59fa5ee..ea59e415 100644 --- a/src/olympic/keel/src/media.cpp +++ b/src/olympic/keel/src/media.cpp @@ -76,8 +76,11 @@ ox::Error buildUuidMap(Context &ctx) noexcept { ox::Result pathToUuid(Context &ctx, ox::StringViewCR path) noexcept { #ifndef OX_BARE_METAL - OX_REQUIRE(out, ctx.pathToUuid.at(path)); - return *out; + auto const out = ctx.pathToUuid.at(path); + if (out.error) { + return ox::Error{1, "Path not found"}; + } + return *out.value; #else return ox::Error(1, "UUID to path conversion not supported on this platform"); #endif