Interface TryCreator

All Superinterfaces:
BodyCreator

public sealed interface TryCreator extends BodyCreator
A creator for a try-catch-finally construct.
  • Method Details

    • body

      void body(Consumer<BlockCreator> builder)
      Build the body of the try statement.
      Specified by:
      body in interface BodyCreator
      Parameters:
      builder - the builder (must not be null)
    • catch_

      default void catch_(ClassDesc type, String caughtName, BiConsumer<BlockCreator,? super LocalVar> builder)
      Add a catch clause which receives the thrown exception.
      Parameters:
      type - the descriptor of the exception type to catch (must not be null)
      caughtName - the name of the caught exception variable (must not be null)
      builder - the builder for the catch block (must not be null)
    • catch_

      void catch_(ClassDesc superType, Set<ClassDesc> types, String caughtName, BiConsumer<BlockCreator,? super LocalVar> builder)
      Add a catch clause for multiple throwable types which receives the thrown exception.
      Parameters:
      superType - the common supertype of all the given types (must not be null)
      types - the exception types to catch (must not be null)
      caughtName - the name of the caught exception variable (must not be null)
      builder - the builder for the catch block (must not be null)
    • catch_

      void catch_(Class<? extends Throwable> type, String caughtName, BiConsumer<BlockCreator,? super LocalVar> builder)
      Add a catch clause which receives the thrown exception.
      Parameters:
      type - the exception type to catch (must not be null)
      caughtName - the name of the caught exception variable (must not be null)
      builder - the builder for the catch block (must not be null)
    • catch_

      void catch_(Set<Class<? extends Throwable>> types, String caughtName, BiConsumer<BlockCreator,? super LocalVar> builder)
      Add a catch clause for multiple throwable types which receives the thrown exception.
      Parameters:
      types - the exception types to catch (must not be null)
      caughtName - the name of the caught exception variable (must not be null)
      builder - the builder for the catch block (must not be null)
    • finally_

      void finally_(Consumer<BlockCreator> builder)
      Add the finally clause. Note that the builder will be called multiple times if there are multiple exit points to the method (which is usually the case).
      Parameters:
      builder - the builder for the finally block (must not be null)