TODO: Review for error recovery
()
| 1474 | |
| 1475 | // TODO: Review for error recovery |
| 1476 | func (p *Parser) parseTryStatement() *ast.Node { |
| 1477 | pos := p.nodePos() |
| 1478 | jsdoc := p.jsdocScannerInfo() |
| 1479 | p.parseExpected(ast.KindTryKeyword) |
| 1480 | tryBlock := p.parseBlock(false /*ignoreMissingOpenBrace*/, nil) |
| 1481 | var catchClause *ast.Node |
| 1482 | if p.token == ast.KindCatchKeyword { |
| 1483 | catchClause = p.parseCatchClause() |
| 1484 | } |
| 1485 | // If we don't have a catch clause, then we must have a finally clause. Try to parse |
| 1486 | // one out no matter what. |
| 1487 | var finallyBlock *ast.Node |
| 1488 | if catchClause == nil || p.token == ast.KindFinallyKeyword { |
| 1489 | p.parseExpectedWithDiagnostic(ast.KindFinallyKeyword, diagnostics.X_catch_or_finally_expected, true /*shouldAdvance*/) |
| 1490 | finallyBlock = p.parseBlock(false /*ignoreMissingOpenBrace*/, nil) |
| 1491 | } |
| 1492 | result := p.finishNode(p.factory.NewTryStatement(tryBlock, catchClause, finallyBlock), pos) |
| 1493 | p.withJSDoc(result, jsdoc) |
| 1494 | return result |
| 1495 | } |
| 1496 | |
| 1497 | func (p *Parser) parseCatchClause() *ast.Node { |
| 1498 | pos := p.nodePos() |
no test coverage detected