1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 08:25:07 +00:00
serenity/Base/home/anon/js/try.js
Andreas Kling 343e224aa8 LibJS: Implement basic exception throwing
You can now throw exceptions by calling Interpreter::throw_exception().
Anyone who calls ASTNode::execute() needs to check afterwards if the
Interpreter now has an exception(), and if so, stop what they're doing
and simply return.

When catching an exception, we'll first execute the CatchClause node
if present. After that, we'll execute the finalizer block if present.

This is unlikely to be completely correct, but it's a start! :^)
2020-03-24 16:14:10 +01:00

10 lines
189 B
JavaScript

try {
console.log("you should see me");
foo();
console.log("not me");
} catch (e) {
console.log("catch");
console.log(e.name);
} finally {
console.log("finally");
}