1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57: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

@ -2006,10 +2006,8 @@ Value TryStatement::execute(Interpreter& interpreter, GlobalObject& global_objec
// If we previously had an exception and the finalizer didn't
// throw a new one, restore the old one.
// FIXME: This will print debug output in throw_exception() for
// a second time with m_should_log_exceptions enabled.
if (previous_exception && !interpreter.exception())
interpreter.vm().throw_exception(previous_exception);
interpreter.vm().set_exception(*previous_exception);
}
}