diff options
author | Linus Groh <mail@linusgroh.de> | 2022-01-08 21:28:27 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-08 23:43:03 +0100 |
commit | eb60d16549eb9415cdbd729afb1f318e8f010dbd (patch) | |
tree | a2cbf9f97cc5b825b0b633b7a6d1d9e9fd7d637a /Userland/Libraries/LibWeb/DOM/Document.cpp | |
parent | f73afbb5ae533706d2445799473de72e7ecfd224 (diff) | |
download | serenity-eb60d16549eb9415cdbd729afb1f318e8f010dbd.zip |
LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.
This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/Document.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 75fcb34f47..170c0a2e7b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -687,10 +687,13 @@ JS::Value Document::run_javascript(StringView source, StringView filename) } auto& interpreter = document().interpreter(); auto& vm = interpreter.vm(); - interpreter.run(interpreter.global_object(), *program); - if (vm.exception()) + auto result = interpreter.run(interpreter.global_object(), *program); + if (result.is_error()) { + // FIXME: I'm sure the spec could tell us something about error propagation here! vm.clear_exception(); - return vm.last_value(); + return {}; + } + return result.value(); } // https://dom.spec.whatwg.org/#dom-document-createelement |