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.
| Constructor and description |
|---|
CatchStatement(Parameter variable, Statement code)Constructs a catch statement with the given exception parameter and code block. |
| 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) |
| 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 |
Returns the statement executed when the exception is caught.
Returns the exception type of this catch statement.
Returns the parameter that declares the caught exception variable.
Sets the statement executed when the exception is caught.
code - the catch block StatementCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.