Class ErrorHandler

java.lang.Object
org.moeaframework.util.ErrorHandler

public class ErrorHandler extends Object
Helper class for managing warnings and errors.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new error handler instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    error(String message)
    Called when an error condition is encountered.
    void
    error(String pattern, Object... arguments)
    Called when an error condition is encountered.
    void
    error(Throwable throwable)
    Called when an exception occurs.
    boolean
    Returns true if an error occurred but was suppressed; false otherwise.
    void
    Clears the state of this error handler.
    void
    setDisplayFullStackTrace(boolean displayFullStackTrace)
    Controls how exceptions are formatted.
    void
    setErrorsAreFatal(boolean errorsAreFatal)
    Controls how errors are handled.
    void
    Sets the stream where warnings and errors are logged.
    void
    setSuppressDuplicates(boolean suppressDuplicates)
    Controls if duplicate logged warnings and errors are displayed or suppressed.
    void
    setWarningsAreFatal(boolean warningsAreFatal)
    Controls how warnings are handled.
    void
    warn(String message)
    Called when a warning condition is encountered.
    void
    warn(String pattern, Object... arguments)
    Called when a warning condition is encountered.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ErrorHandler

      public ErrorHandler()
      Constructs a new error handler instance.
  • Method Details

    • isError

      public boolean isError()
      Returns true if an error occurred but was suppressed; false otherwise.
      Returns:
      if an error occurred
    • reset

      public void reset()
      Clears the state of this error handler.
    • setMessageStream

      public void setMessageStream(PrintStream messageStream)
      Sets the stream where warnings and errors are logged. Note that this stream is not managed by this class and will not be closed.
      Parameters:
      messageStream - the new stream
    • setSuppressDuplicates

      public void setSuppressDuplicates(boolean suppressDuplicates)
      Controls if duplicate logged warnings and errors are displayed or suppressed. If true, each unique warning or error is logged once.
      Parameters:
      suppressDuplicates - the new duplicate message behavior
    • setErrorsAreFatal

      public void setErrorsAreFatal(boolean errorsAreFatal)
      Controls how errors are handled. If false, any errors are logged but suppressed. If true, an exception is thrown.
      Parameters:
      errorsAreFatal - the new error handling behavior
    • setWarningsAreFatal

      public void setWarningsAreFatal(boolean warningsAreFatal)
      Controls how warnings are handled. If false, any warnings are logged but suppressed. If true, an exception is thrown.
      Parameters:
      warningsAreFatal - the new setting
    • setDisplayFullStackTrace

      public void setDisplayFullStackTrace(boolean displayFullStackTrace)
      Controls how exceptions are formatted. If true, the full stack trace is displayed. If false, only the message is displayed.
      Parameters:
      displayFullStackTrace - the new setting
    • warn

      public void warn(String message) throws IOException
      Called when a warning condition is encountered.
      Parameters:
      message - the warning message
      Throws:
      IOException - if warningsAreFatal is true
    • warn

      public void warn(String pattern, Object... arguments) throws IOException
      Called when a warning condition is encountered.
      Parameters:
      pattern - the warning message pattern used by MessageFormat
      arguments - the arguments used to format the message
      Throws:
      IOException - if warningsAreFatal is true
    • error

      public void error(String message) throws IOException
      Called when an error condition is encountered.
      Parameters:
      message - the error message
      Throws:
      IOException - if errorsAreFatal is true
    • error

      public void error(String pattern, Object... arguments) throws IOException
      Called when an error condition is encountered.
      Parameters:
      pattern - the error message pattern used by MessageFormat
      arguments - the arguments used to format the message
      Throws:
      IOException - if errorsAreFatal is true
    • error

      public void error(Throwable throwable) throws IOException
      Called when an exception occurs.
      Parameters:
      throwable - the exception
      Throws:
      IOException - if errorsAreFatal is true