Interface ExceptionSubscriber

  • All Known Implementing Classes:
    ExceptionAnalyzer, ExceptionEmailer

    public interface ExceptionSubscriber
    An ExceptionSubscriber is an entity that is informed of exceptions and the handling policy for exceptions caught by CatchExceptionAttribute. The ExceptionSubscriber can then take some action, if desired. For example, actors that communicate with outside clients may want to pass along information about the error that has occurred, instead of returning a generic message or a timeout error response. This follows the Command design pattern, where the invoker is CatchExceptionAttribute, the client is the Ptolemy developer (defines commands by dragging and dropping attributes into the model), and the receiver is a Ptolemy entity (such as an attribute that writes to a file.
    Since:
    Ptolemy II 10.0
    Version:
    $Id: ExceptionSubscriber.java 69467 2014-06-29 14:35:19Z beth@berkeley.edu$
    Author:
    Elizabeth Latronico
    See Also:
    CatchExceptionAttribute
    Pt.AcceptedRating:
    Red (beth)
    Pt.ProposedRating:
    Red (beth)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean exceptionHandled​(boolean successful, java.lang.String message)
      Invoked by an exception handler (e.g.
      boolean exceptionOccurred​(java.lang.String policy, java.lang.Throwable exception)
      Action to execute upon the occurrence of an exception.
    • Method Detail

      • exceptionOccurred

        boolean exceptionOccurred​(java.lang.String policy,
                                  java.lang.Throwable exception)
        Action to execute upon the occurrence of an exception. Some ExceptionReactions may need to set up and close access to resources (such as opening and closing a file). These could extend AbstractInitalizableAttribute to do so.
        Parameters:
        policy - The handling policy of the exception manager (for example, restart); see CatchExceptionAttribute
        exception - The exception
        Returns:
        True if the subscriber successfully processed the information; false otherwise (for example, an ExceptionEmailer that fails to send an email)
      • exceptionHandled

        boolean exceptionHandled​(boolean successful,
                                 java.lang.String message)
        Invoked by an exception handler (e.g. ExceptionManager) after an exception has been handled.
        Parameters:
        successful - True if the exception was successfully handled; false otherwise
        message - A status message from the exception handler
        Returns:
        True if the subscriber successfully processed the information; false otherwise (for example, an ExceptionEmailer that fails to send an email)