mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
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().
This commit is contained in:
parent
f73afbb5ae
commit
eb60d16549
13 changed files with 62 additions and 56 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue