From 9e50bd91a6d7ceb9a00ce0d66443de578bb31023 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 4 Jan 2022 22:54:31 +0100 Subject: [PATCH] js: Remove uses of TRY_OR_DISCARD() Slightly more verbose, but that's the last user of TRY_OR_DISCARD gone! --- Userland/Utilities/js.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 8d65721270..7c91bb09d0 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -1426,12 +1426,15 @@ ErrorOr serenity_main(Main::Arguments arguments) switch (mode) { case CompleteProperty: { - Optional maybe_value; - auto maybe_variable = TRY_OR_DISCARD(vm->resolve_binding(variable_name, &global_environment)); - maybe_value = TRY_OR_DISCARD(maybe_variable.get_value(interpreter->global_object())); - VERIFY(!maybe_value->is_empty()); + auto reference_or_error = vm->resolve_binding(variable_name, &global_environment); + if (reference_or_error.is_error()) + return {}; + auto value_or_error = reference_or_error.value().get_value(interpreter->global_object()); + if (value_or_error.is_error()) + return {}; + auto variable = value_or_error.value(); + VERIFY(!variable.is_empty()); - auto variable = *maybe_value; if (!variable.is_object()) break;