Package: org.codehaus.groovy.ast.stmt

## [Java] Class CatchStatement

- org.codehaus.groovy.ast.stmt.CatchStatement

-     public class CatchStatement
      extends Statement

  Represents a catch (Exception var) { } statement that handles exceptions in a try-catch block. Each catch statement specifies an exception type to handle and a code block to execute when an exception of that type is caught. The exception is bound to a variable that can be referenced within the catch block.

  See Also:
    TryCatchStatement
    Parameter
    Statement

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CatchStatement(Parameter variable, Statement code)` Constructs a catch statement with the given exception parameter and code block.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Statement` | `getCode()` Returns the statement executed when the exception is caught.
    `` | `public ClassNode` | `getExceptionType()` Returns the exception type of this catch statement.
    `` | `public Parameter` | `getVariable()` Returns the parameter that declares the caught exception variable.
    `` | `public void` | `setCode(Statement code)` Sets the statement executed when the exception is caught.
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Statement` | `addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabel`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public CatchStatement(Parameter variable, Statement code)

      Constructs a catch statement with the given exception parameter and code block.

      Parameters:
        `variable` - the Parameter that declares the caught exception and binds it to a variable name
        `code` - the Statement to execute when the exception is caught

  - ### Method Detail

    - #### public Statement getCode()

      Returns the statement executed when the exception is caught.

      Returns:
        the catch block Statement

    - #### public ClassNode getExceptionType()

      Returns the exception type of this catch statement.

      Returns:
        the ClassNode representing the exception type

    - #### public Parameter getVariable()

      Returns the parameter that declares the caught exception variable.

      Returns:
        the exception Parameter

    - #### public void setCode(Statement code)

      Sets the statement executed when the exception is caught.

      Parameters:
        `code` - the catch block Statement

    - #### public void visit(GroovyCodeVisitor visitor)