Package org.moeaframework.util
Class ErrorHandler
java.lang.Object
org.moeaframework.util.ErrorHandler
Helper class for managing warnings and errors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when an error condition is encountered.voidCalled when an error condition is encountered.voidCalled when an exception occurs.booleanisError()Returnstrueif an error occurred but was suppressed;falseotherwise.voidreset()Clears the state of this error handler.voidsetDisplayFullStackTrace(boolean displayFullStackTrace) Controls how exceptions are formatted.voidsetErrorsAreFatal(boolean errorsAreFatal) Controls how errors are handled.voidsetMessageStream(PrintStream messageStream) Sets the stream where warnings and errors are logged.voidsetSuppressDuplicates(boolean suppressDuplicates) Controls if duplicate logged warnings and errors are displayed or suppressed.voidsetWarningsAreFatal(boolean warningsAreFatal) Controls how warnings are handled.voidCalled when a warning condition is encountered.voidCalled when a warning condition is encountered.
-
Constructor Details
-
ErrorHandler
public ErrorHandler()Constructs a new error handler instance.
-
-
Method Details
-
isError
public boolean isError()Returnstrueif an error occurred but was suppressed;falseotherwise.- Returns:
- if an error occurred
-
reset
public void reset()Clears the state of this error handler. -
setMessageStream
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. Iftrue, 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. Iffalse, any errors are logged but suppressed. Iftrue, an exception is thrown.- Parameters:
errorsAreFatal- the new error handling behavior
-
setWarningsAreFatal
public void setWarningsAreFatal(boolean warningsAreFatal) Controls how warnings are handled. Iffalse, any warnings are logged but suppressed. Iftrue, an exception is thrown.- Parameters:
warningsAreFatal- the new setting
-
setDisplayFullStackTrace
public void setDisplayFullStackTrace(boolean displayFullStackTrace) Controls how exceptions are formatted. Iftrue, the full stack trace is displayed. Iffalse, only the message is displayed.- Parameters:
displayFullStackTrace- the new setting
-
warn
Called when a warning condition is encountered.- Parameters:
message- the warning message- Throws:
IOException- ifwarningsAreFatalistrue
-
warn
Called when a warning condition is encountered.- Parameters:
pattern- the warning message pattern used byMessageFormatarguments- the arguments used to format the message- Throws:
IOException- ifwarningsAreFatalistrue
-
error
Called when an error condition is encountered.- Parameters:
message- the error message- Throws:
IOException- iferrorsAreFatalistrue
-
error
Called when an error condition is encountered.- Parameters:
pattern- the error message pattern used byMessageFormatarguments- the arguments used to format the message- Throws:
IOException- iferrorsAreFatalistrue
-
error
Called when an exception occurs.- Parameters:
throwable- the exception- Throws:
IOException- iferrorsAreFatalistrue
-