forked from dsherret/ts-morph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CatchClause.ts
29 lines (26 loc) · 989 Bytes
/
CatchClause.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as errors from "../../../errors";
import { ts } from "../../../typescript";
import { Node } from "../common";
import { Block } from "./Block";
import { VariableDeclaration } from "../variable";
export const CatchClauseBase = Node;
export class CatchClause extends CatchClauseBase<ts.CatchClause> {
/**
* Gets this catch clause's block.
*/
getBlock(): Block {
return this._getNodeFromCompilerNode(this.compilerNode.block);
}
/**
* Gets this catch clause's variable declaration or undefined if none exists.
*/
getVariableDeclaration(): VariableDeclaration | undefined {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.variableDeclaration);
}
/**
* Gets this catch clause's variable declaration or throws if none exists.
*/
getVariableDeclarationOrThrow() {
return errors.throwIfNullOrUndefined(this.getVariableDeclaration(), "Expected to find a variable declaration.");
}
}