Skip to content
Nelson Tavares de Sousa edited this page Sep 18, 2015 · 1 revision

This is still in development #32 . Check the snapshot version, if you need this funcionality

Exception Handling in TeeTime

TeeTime introduces a handling mechanism to examine exceptions within the execution of analysis. For this to work, a listener will be added to every single created thread. You can rely on the provided listeners or extend the framework by implementing your own. This page will introduce you to the mechanism and explain how to integrate your own approaches into TeeTime.

Passing of exceptions

If you implement your own Stage and need Exceptions, you can simply throw a RuntimeException (or its subclasses) from the execute() method. All thrown exceptions will be catched and passed on to a listener, which monitors all stages within the thread. You do not need to take care of anything else.

Selecting a listener

TeeTime uses the IgnoringStageListener as default listener for analysis execution. If you want to use a different listener, you need to specify it within the institution of Analysis. There are different constructors for Analysis, which use the default listener or a specific one. More on this can be found in the documentation. TeeTime comes with a set of implemented Listeners, such as:

  • LoggingStageListener: Logs the exception and continues the execution of the thread.
  • IgnoringStageListener: Simply ignores the exception
  • TerminatingStageListener: Logs the exception and terminates the execution of the thread

Implement your own StageExceptionListener

If you need different functionality, you can simply implement your own listener. You need to extend the abstract class StageExceptionListener. This comes with some tools, which you can use. One if them is the logger instance. You can use the attribute logger for debugging purposes. Furthermore it is possible to terminate the thread's execution. More on this later.

Your own listener needs to implement the method onStageException(Exception e, Stage throwingStage). With e you can examine the thrown Exception and throwingStage contains the exact Stage in which the Exception was thrown. It is not relevant if the thread contains more than one stage. Only the throwing Stage will be reported to the listener. The return value of this method is a enum. You need to return CONTINUE, if execution of the thread can be continued, TERMINATE otherwise. This will lead to a termination of the thread, sending a TerminationSignal to following stages and finally a termination of the whole analysis.