From 2219eef2504b84fa9c785367db52b5f7b206c7ab Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 22 Mar 2022 12:40:24 +0000 Subject: [PATCH] LibWeb: Convert Text to use TRY for error propagation --- Userland/Libraries/LibWeb/DOM/Text.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 6e45de9fbd..83b21fcdd7 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -43,10 +43,7 @@ ExceptionOr> Text::split_text(size_t offset) auto count = length - offset; // 4. Let new data be the result of substringing data with node node, offset offset, and count count. - auto new_data_or_error = substring_data(offset, count); - if (new_data_or_error.is_exception()) - return new_data_or_error.exception(); - auto new_data = new_data_or_error.release_value(); + auto new_data = TRY(substring_data(offset, count)); // 5. Let new node be a new Text node, with the same node document as node. Set new node’s data to new data. auto new_node = adopt_ref(*new Text(document(), new_data)); @@ -86,8 +83,7 @@ ExceptionOr> Text::split_text(size_t offset) } // 8. Replace data with node node, offset offset, count count, and data the empty string. - if (auto result = replace_data(offset, count, ""); result.is_exception()) - return result.exception(); + TRY(replace_data(offset, count, "")); // 9. Return new node. return new_node;