LibWeb/IDB: Introduce an Invalid KeyType

This cleans up the code around failure/invalid/exception a bit
This commit is contained in:
stelar7 2025-04-25 17:59:06 +02:00 committed by Jelle Raaijmakers
commit facfcd87c2
Notes: github-actions[bot] 2025-04-28 09:32:57 +00:00
7 changed files with 68 additions and 56 deletions

View file

@ -108,18 +108,18 @@ WebIDL::ExceptionOr<i8> IDBFactory::cmp(JS::Value first, JS::Value second)
auto a = TRY(convert_a_value_to_a_key(realm(), first));
// 2. If a is invalid, throw a "DataError" DOMException.
if (a.is_error())
if (a->is_invalid())
return WebIDL::DataError::create(realm(), "Failed to convert a value to a key"_string);
// 3. Let b be the result of converting a value to a key with second. Rethrow any exceptions.
auto b = TRY(convert_a_value_to_a_key(realm(), second));
// 4. If b is invalid, throw a "DataError" DOMException.
if (b.is_error())
if (b->is_invalid())
return WebIDL::DataError::create(realm(), "Failed to convert a value to a key"_string);
// 5. Return the results of comparing two keys with a and b.
return Key::compare_two_keys(a.release_value(), b.release_value());
return Key::compare_two_keys(a, b);
}
// https://w3c.github.io/IndexedDB/#dom-idbfactory-deletedatabase