MCPcopy
hub / github.com/jquery/esprima / parseCatchClause

Method parseCatchClause

src/parser.ts:2567–2598  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2565 // https://tc39.github.io/ecma262/#sec-try-statement
2566
2567 parseCatchClause(): Node.CatchClause {
2568 const node = this.createNode();
2569
2570 this.expectKeyword('catch');
2571
2572 this.expect('(');
2573 if (this.match(')')) {
2574 this.throwUnexpectedToken(this.lookahead);
2575 }
2576
2577 const params: any[] = [];
2578 const param = this.parsePattern(params);
2579 const paramMap = {};
2580 for (let i = 0; i < params.length; i++) {
2581 const key = '$' + params[i].value;
2582 if (Object.prototype.hasOwnProperty.call(paramMap, key)) {
2583 this.tolerateError(Messages.DuplicateBinding, params[i].value);
2584 }
2585 paramMap[key] = true;
2586 }
2587
2588 if (this.context.strict && param.type === Syntax.Identifier) {
2589 if (this.scanner.isRestrictedWord((param as Node.Identifier).name)) {
2590 this.tolerateError(Messages.StrictCatchVariable);
2591 }
2592 }
2593
2594 this.expect(')');
2595 const body = this.parseBlock();
2596
2597 return this.finalize(node, new Node.CatchClause(param, body));
2598 }
2599
2600 parseFinallyClause(): Node.BlockStatement {
2601 this.expectKeyword('finally');

Callers 1

parseTryStatementMethod · 0.95

Calls 10

createNodeMethod · 0.95
expectKeywordMethod · 0.95
expectMethod · 0.95
matchMethod · 0.95
throwUnexpectedTokenMethod · 0.95
parsePatternMethod · 0.95
tolerateErrorMethod · 0.95
parseBlockMethod · 0.95
finalizeMethod · 0.95
isRestrictedWordMethod · 0.80

Tested by

no test coverage detected