summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-03-22 12:37:47 +0000
committerLinus Groh <mail@linusgroh.de>2022-03-22 18:05:25 +0000
commitb6f09aaef233da7924d4c78f0848ca702c0e60ac (patch)
tree4bd5f9f5c451c6681fc22ac7499f663fe2f3cea8 /Userland/Libraries/LibWeb/DOM
parent91d0088a5b73e0c880591431ecbc6772011dc799 (diff)
downloadserenity-b6f09aaef233da7924d4c78f0848ca702c0e60ac.zip
LibWeb: Convert DOMTokenList to use TRY for error propagation
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp
index 9d375e8d1f..902a12d856 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp
+++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp
@@ -109,8 +109,7 @@ ExceptionOr<void> DOMTokenList::add(Vector<String> const& tokens)
for (auto const& token : tokens) {
// a. If token is the empty string, then throw a "SyntaxError" DOMException.
// b. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
- if (auto exception = validate_token(token); exception.is_exception())
- return exception;
+ TRY(validate_token(token));
// 2. For each token in tokens, append token to this’s token set.
append_to_ordered_set(m_token_set, token);
@@ -128,8 +127,7 @@ ExceptionOr<void> DOMTokenList::remove(Vector<String> const& tokens)
for (auto const& token : tokens) {
// a. If token is the empty string, then throw a "SyntaxError" DOMException.
// b. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
- if (auto exception = validate_token(token); exception.is_exception())
- return exception;
+ TRY(validate_token(token));
// 2. For each token in tokens, remove token from this’s token set.
remove_from_ordered_set(m_token_set, token);
@@ -145,8 +143,7 @@ ExceptionOr<bool> DOMTokenList::toggle(String const& token, Optional<bool> force
{
// 1. If token is the empty string, then throw a "SyntaxError" DOMException.
// 2. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
- if (auto exception = validate_token(token); exception.is_exception())
- return exception.exception();
+ TRY(validate_token(token));
// 3. If this’s token set[token] exists, then:
if (contains(token)) {
@@ -177,10 +174,8 @@ ExceptionOr<bool> DOMTokenList::replace(String const& token, String const& new_t
{
// 1. If either token or newToken is the empty string, then throw a "SyntaxError" DOMException.
// 2. If either token or newToken contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
- if (auto exception = validate_token(token); exception.is_exception())
- return exception.exception();
- if (auto exception = validate_token(new_token); exception.is_exception())
- return exception.exception();
+ TRY(validate_token(token));
+ TRY(validate_token(new_token));
// 3. If this’s token set does not contain token, then return false.
if (!contains(token))