Enum Class ErrorStrategy

java.lang.Object
java.lang.Enum<ErrorStrategy>
nl.tudelft.simulation.dsol.simulators.ErrorStrategy
All Implemented Interfaces:
Serializable, Comparable<ErrorStrategy>, java.lang.constant.Constable

public enum ErrorStrategy extends Enum<ErrorStrategy>
ErrorStrategy indicates what to do when there is an error in the execution of the simulation. In order to set the error handling, the setPauseOnError() and isPauseOnError() methods are deprecated and replaced by new setErrorStrategy(ErrorStrategy strategy) and getErrorStrategy() methods. The log level can be overridden (and even be set to NONE).

Copyright (c) 2021-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.

Author:
Alexander Verbraeck
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Send the error to the logger as WARNING.
    Send the error to logger as ERROR and print the exception on stderr.
    Send the error to logger as ERROR and print the exception on stderr The Simulator.cleanup() method is called to ensure the SimulatorWorkerThread.run() method completely ends and can be garbage collected.
    Send the error to logger as ERROR and print the exception on stderr The Simulator.cleanup() method is called to ensure the stop of the run() in SimulatorWorkerThread; the System.exit() method is called to end the complete program.
    Send the error to logger as ERROR and print the exception on stderr The RunState goes to STOPPING, leading to the stop of the loop in the Simulator.run() method and a subsequent STOPPED state in the SimulatorWorkerThread.run() method.
  • Method Summary

    Modifier and Type
    Method
    Description
    final Level
    Return the default log level for the ErrorStrategy (can be overridden in the Simulator) .
    Returns the enum constant of this class with the specified name.
    static ErrorStrategy[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • LOG_AND_CONTINUE

      public static final ErrorStrategy LOG_AND_CONTINUE
      Send the error to the logger as WARNING. Both RunState and ReplicationState remain in the RUNNING state. The Simulator.run() continues as if the error did not occur.
    • WARN_AND_CONTINUE

      public static final ErrorStrategy WARN_AND_CONTINUE
      Send the error to logger as ERROR and print the exception on stderr. Both RunState and ReplicationState remain in the RUNNING state. The Simulator.run() continues as if the error did not occur.
    • WARN_AND_PAUSE

      public static final ErrorStrategy WARN_AND_PAUSE
      Send the error to logger as ERROR and print the exception on stderr The RunState goes to STOPPING, leading to the stop of the loop in the Simulator.run() method and a subsequent STOPPED state in the SimulatorWorkerThread.run() method. The SimulatorWorkerThread will go into a Thread.wait(), to wait for start (or cleanup).
    • WARN_AND_END

      public static final ErrorStrategy WARN_AND_END
      Send the error to logger as ERROR and print the exception on stderr The Simulator.cleanup() method is called to ensure the SimulatorWorkerThread.run() method completely ends and can be garbage collected. If there is a UI thread, it will keep running.
    • WARN_AND_EXIT

      public static final ErrorStrategy WARN_AND_EXIT
      Send the error to logger as ERROR and print the exception on stderr The Simulator.cleanup() method is called to ensure the stop of the run() in SimulatorWorkerThread; the System.exit() method is called to end the complete program.
  • Method Details

    • values

      public static ErrorStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ErrorStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDefaultLogLevel

      public final Level getDefaultLogLevel()
      Return the default log level for the ErrorStrategy (can be overridden in the Simulator) .
      Returns:
      Level: the default log level for the ErrorStrategy