agsamantha/node_modules/jintr/dist/nodes/TryStatement.js

20 lines
629 B
JavaScript
Raw Normal View History

2024-10-02 20:15:21 +00:00
import BaseJSNode from './BaseJSNode.js';
export default class TryStatement extends BaseJSNode {
run() {
try {
return this.visitor.visitNode(this.node.block);
}
catch (e) {
if (this.node.handler) {
if (this.node.handler.param && this.node.handler.param.type === 'Identifier') {
this.visitor.scope.set(this.node.handler.param.name, e);
}
return this.visitor.visitNode(this.node.handler.body);
}
}
finally {
this.visitor.visitNode(this.node.finalizer);
}
}
}