Package org.apache.tapestry5.plastic
Interface TryCatchBlock
- All Known Implementing Classes:
TryCatchBlockImpl
public interface TryCatchBlock
Allows a portion of a method to be marked so that exception and finally handlers can be provided.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCatch
(String exceptionClassName, InstructionBuilderCallback callback) Ends the block (if not already ended) and inserts a catch block for the named exception.void
addFinally
(InstructionBuilderCallback callback) As withaddCatch(String, InstructionBuilderCallback)
, but the exception caught is null, which acts as a finally block in the Java language.void
addTry
(InstructionBuilderCallback callback) Invoked first, to generate the code in which exceptions may be caught.
-
Method Details
-
addTry
Invoked first, to generate the code in which exceptions may be caught. -
addCatch
@Opcodes("TRYCATCHBLOCK") void addCatch(String exceptionClassName, InstructionBuilderCallback callback) Ends the block (if not already ended) and inserts a catch block for the named exception. The InstructionBuilder is returned so that the code for handling the exception can be added. The exception object will be on top of the stack. This should be called afteraddTry(InstructionBuilderCallback)
. Note: no attempt is made currently to sort the handlers; for example adding a catch for java.lang.Exception first will mean that more specific exception handlers added later will never be invoked.- Parameters:
exceptionClassName
- caught exception classcallback
- that implements the logic of the catch block
-
addFinally
As withaddCatch(String, InstructionBuilderCallback)
, but the exception caught is null, which acts as a finally block in the Java language. This must be called last (afteraddTry(InstructionBuilderCallback)
and any calls toaddCatch(String, InstructionBuilderCallback)
.- Parameters:
callback
- implements the logic of the finally block
-