[keel] Add clearer Error handling
This commit is contained in:
		@@ -63,8 +63,11 @@ namespace detail {
 | 
				
			|||||||
template<typename T>
 | 
					template<typename T>
 | 
				
			||||||
constexpr auto makeLoader(Context &ctx) {
 | 
					constexpr auto makeLoader(Context &ctx) {
 | 
				
			||||||
	return [&ctx](ox::StringViewCR assetId) -> ox::Result<T> {
 | 
						return [&ctx](ox::StringViewCR assetId) -> ox::Result<T> {
 | 
				
			||||||
		OX_REQUIRE(p, ctx.uuidToPath.at(assetId));
 | 
							auto const p = ctx.uuidToPath.at(assetId);
 | 
				
			||||||
		OX_REQUIRE(buff, ctx.rom->read(*p));
 | 
							if (p.error) {
 | 
				
			||||||
 | 
								return ox::Error{1, "Asset ID not found"};
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							OX_REQUIRE(buff, ctx.rom->read(*p.value));
 | 
				
			||||||
		auto [obj, err] = readAsset<T>(buff);
 | 
							auto [obj, err] = readAsset<T>(buff);
 | 
				
			||||||
		if (err) {
 | 
							if (err) {
 | 
				
			||||||
			if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) {
 | 
								if (err != ox::Error_ClawTypeVersionMismatch && err != ox::Error_ClawTypeMismatch) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,8 +76,11 @@ ox::Error buildUuidMap(Context &ctx) noexcept {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept {
 | 
					ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept {
 | 
				
			||||||
#ifndef OX_BARE_METAL
 | 
					#ifndef OX_BARE_METAL
 | 
				
			||||||
	OX_REQUIRE(out, ctx.pathToUuid.at(path));
 | 
						auto const out = ctx.pathToUuid.at(path);
 | 
				
			||||||
	return *out;
 | 
						if (out.error) {
 | 
				
			||||||
 | 
							return ox::Error{1, "Path not found"};
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return *out.value;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	return ox::Error(1, "UUID to path conversion not supported on this platform");
 | 
						return ox::Error(1, "UUID to path conversion not supported on this platform");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user