Class CatchExceptionAttribute

    • Field Detail

      • exceptionMessage

        public StringParameter exceptionMessage
        The exception message from the caught exception.
      • logFileName

        public FileParameter logFileName
        The file, if any, to log messages to.
      • policy

        public StringParameter policy
        The error handling policy to apply if an exception occurs. One of: Continue, Throw, Restart, Quit
      • statusMessage

        public StringParameter statusMessage
        The latest action, if any, taken by the CatchExceptionAttribute. For example, a notification that the model has restarted. It offers a way to provide feedback to the user.
      • CONTINUE

        public static final java.lang.String CONTINUE
        String value for the "continue" policy.
        See Also:
        Constant Field Values
      • RESTART

        public static final java.lang.String RESTART
        String value for the "restart" policy.
        See Also:
        Constant Field Values
      • THROW

        public static final java.lang.String THROW
        String value for the "throw" policy.
        See Also:
        Constant Field Values
      • STOP

        public static final java.lang.String STOP
        String value for the "stop" policy.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CatchExceptionAttribute

        public CatchExceptionAttribute​(CompositeEntity container,
                                       java.lang.String name)
                                throws NameDuplicationException,
                                       IllegalActionException
        Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
        Parameters:
        container - The container.
        name - The name of this actor within the container.
        Throws:
        IllegalActionException - If this actor cannot be contained by the proposed container (see the setContainer() method).
        NameDuplicationException - If the name coincides with an entity already in the container.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        React to a change in an attribute. This method is called by a contained attribute when its value changes. In this base class, the method does nothing. In derived classes, this method may throw an exception, indicating that the new attribute value is invalid. It is up to the caller to restore the attribute to a valid value if an exception is thrown.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - If the change is not acceptable to this container (not thrown in this base class).
      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone the attribute into the specified workspace.
        Overrides:
        clone in class AbstractInitializableAttribute
        Parameters:
        workspace - The workspace for the new object.
        Returns:
        A new actor.
        Throws:
        java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.
        See Also:
        Object.clone()
      • executionError

        public void executionError​(Manager manager,
                                   java.lang.Throwable throwable)
        Do nothing upon execution error. Exceptions are passed to this attribute through handleException(). This method is required by the ExecutionListener interface.
        Specified by:
        executionError in interface ExecutionListener
        Parameters:
        manager - Ignored.
        throwable - Ignored.
      • executionFinished

        public void executionFinished​(Manager manager)
        Restart here if restart is desired. This method is called upon successful completion.
        Specified by:
        executionFinished in interface ExecutionListener
        Parameters:
        manager - The manager that starts the run.
      • handleException

        public boolean handleException​(NamedObj context,
                                       java.lang.Throwable exception)
                                throws IllegalActionException
        Handle an exception according to the specified policy: continue: Not implemented yet Consume the exception and return control to the director. Could be valuable for domains like DE or modal models when new events will arrive. Probably not appropriate for domains like SDF where the director follows a predefined schedule based on data flow (since the actor throwing the exception no longer provides output to the next actor). throw: Do not catch the exception. restart: Stop and restart the model. Does not apply to exceptions generated during initialize(). stop: Stop the model.
        Specified by:
        handleException in interface ExceptionHandler
        Parameters:
        context - The object in which the error occurred.
        exception - The exception to be handled.
        Returns:
        true if the exception is handled; false if this attribute did not handle it
        Throws:
        IllegalActionException - If thrown by the parent
      • _writeMessage

        protected void _writeMessage​(java.lang.String message)
                              throws java.io.IOException
        Write the given message to the statusMessage parameter and to the log file, if open.
        Parameters:
        message - The message to write
        Throws:
        java.io.IOException - If there is a problem writing to the file