Class TryCatchStatement

All Implemented Interfaces:
NodeMetaDataHandler

public class TryCatchStatement extends Statement
Represents a try { ... } catch { ... } finally { ... } statement in Groovy. A try-catch statement combines exception handling with optional resource management (try-with-resources). It contains a main try block, zero or more CatchStatements for exception handlers, an optional finally block, and optional resource declarations that implement AutoCloseable.
See Also:
  • Constructor Details

    • TryCatchStatement

      public TryCatchStatement(Statement tryStatement, Statement finallyStatement)
      Constructs a TryCatchStatement with a try block and optional finally block. Catch statements and resource statements should be added separately via addCatch(CatchStatement) and addResource(ExpressionStatement).
      Parameters:
      tryStatement - the Statement to execute as the try block
      finallyStatement - the Statement to execute in the finally block, or null if no finally clause
  • Method Details