Package org.moeaframework.util
Class ErrorHandler
java.lang.Object
org.moeaframework.util.ErrorHandler
Helper class for managing warnings and errors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when an error condition is encountered.void
Called when an error condition is encountered.void
Called when an exception occurs.boolean
isError()
Returnstrue
if an error occurred but was suppressed;false
otherwise.void
reset()
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
setMessageStream
(PrintStream messageStream) 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
Called when a warning condition is encountered.void
Called when a warning condition is encountered.
-
Constructor Details
-
ErrorHandler
public ErrorHandler()Constructs a new error handler instance.
-
-
Method Details
-
isError
public boolean isError()Returnstrue
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
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
- ifwarningsAreFatal
istrue
-
warn
Called when a warning condition is encountered.- Parameters:
pattern
- the warning message pattern used byMessageFormat
arguments
- the arguments used to format the message- Throws:
IOException
- ifwarningsAreFatal
istrue
-
error
Called when an error condition is encountered.- Parameters:
message
- the error message- Throws:
IOException
- iferrorsAreFatal
istrue
-
error
Called when an error condition is encountered.- Parameters:
pattern
- the error message pattern used byMessageFormat
arguments
- the arguments used to format the message- Throws:
IOException
- iferrorsAreFatal
istrue
-
error
Called when an exception occurs.- Parameters:
throwable
- the exception- Throws:
IOException
- iferrorsAreFatal
istrue
-