1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibJS: Add set_exception() and change throw_exception() to take a reference

Sometimes we just want to set m_exception to some value we stored
previously, without really "throwing" it again - that's what
set_exception() does now. Since we have clear_exception(), it does take
a reference, i.e. you don't set_exception(nullptr). For consistency I
updated throw_exception() to do the same.
This commit is contained in:
Linus Groh 2021-04-13 01:02:38 +02:00 committed by Andreas Kling
parent f2abe42ecb
commit 4ee965f916
3 changed files with 8 additions and 13 deletions

View file

@ -290,10 +290,10 @@ Value VM::construct(Function& function, Function& new_target, Optional<MarkedVal
return this_value;
}
void VM::throw_exception(Exception* exception)
void VM::throw_exception(Exception& exception)
{
if (should_log_exceptions()) {
auto value = exception->value();
auto value = exception.value();
if (value.is_object()) {
auto& object = value.as_object();
auto name = object.get_without_side_effects(names.name).value_or(js_undefined());
@ -317,7 +317,7 @@ void VM::throw_exception(Exception* exception)
}
}
m_exception = exception;
set_exception(exception);
unwind(ScopeType::Try);
}