public interface ErrorMsgOps
Error message interface.
This interface provides a common interface for reporting errors.
Classes that implement this interface will determine where and
how the error message is displayed.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a separator.void
Add separator if needed.void
Display a message.void
Display a message with a file name and line number.void
Display a message with a title.void
Display an error message, based on an exception, with a line from some input.void
Display a Throwable with a prefix.void
Display a Throwable.void
Display a console if there is one, if it is an instance ofSimpleConsole
, and if there is new text to display.void
displayFormat
(String title, String format, Object... args) Display formatted text with a title using the default locale.void
displayFormat
(String title, Locale locale, String format, Object... args) Display formatted text with a title for a specific locale.void
Display formatted text using the default locale.void
Display formatted text for a specific locale.void
setAppendable
(Appendable out) Set the Appendable recording error messages.void
setStackTrace
(boolean value) Set stack-trace recording.boolean
Check if stack traces are enabled.
-
Method Details
-
addSeparatorIfNeeded
void addSeparatorIfNeeded()Add separator if needed. -
addSeparator
void addSeparator()Add a separator. -
setStackTrace
void setStackTrace(boolean value) Set stack-trace recording. Determines if a stack trace is shown when a Throwable is displayed.- Parameters:
value
- true if stack traces should be recorded; false otherwise- See Also:
-
stackTraceEnabled
boolean stackTraceEnabled()Check if stack traces are enabled.- Returns:
- true if stack traces are enabled; false otherwise
- See Also:
-
setAppendable
Set the Appendable recording error messages. The default is System.err. The methoddisplayConsoleIfNeeded()
will display a console if it is passed to this method and if it is an instance ofSimpleConsole
. To use the Java console for output (the TTY associated with a process on Unix/Linux), try setAppendable(System.console().writer()); however, normally one would just use System.err.- Parameters:
out
- the Appendable for error messages; null for the default.
-
display
Display a message with a file name and line number.- Parameters:
fn
- the file namelineno
- the line numbermsg
- the message to display
-
display
void display(String fn, String input, int index, Exception e, boolean verbose, boolean showLocation) Display an error message, based on an exception, with a line from some input. The default format in English shows the filename in quotes followed by the line number, the class for the exception, and the corresponding message. The next line contains a portion of the input, with a subsequent line including a caret indicating the point where the error occurred, followed by some information about the column number.- Parameters:
fn
- a file name or other name for the inputinput
- the input being processedindex
- a location in the input where an error occurrede
- the exception that generated an errorverbose
- true if a long format should be usedshowLocation
- true if line number and column numbers should be shown; false otherwise
-
displayConsoleIfNeeded
void displayConsoleIfNeeded()Display a console if there is one, if it is an instance ofSimpleConsole
, and if there is new text to display. For aSimpleConsole
to be available, it must have been passed tosetAppendable(Appendable)
. -
display
Display a Throwable with a prefix. at a minimum, the Throwable's message will be displayed. Optionally, a stack trace may be displayed as well.- Parameters:
prefix
- a prefix to show before a stack trace, typically consisting of spacest
- the Throwable- See Also:
-
display
Display a Throwable. at a minimum, the Throwable's message will be displayed. Optionally, a stack trace may be displayed as well.- Parameters:
t
- the Throwable- See Also:
-
display
Display a message.- Parameters:
msg
- the message to display
-
format
Display formatted text using the default locale. SeeFormatter
for a description of the format string.- Parameters:
format
- a format stringargs
- the arguments to format
-
format
Display formatted text for a specific locale. SeeFormatter
for a description of the format string.- Parameters:
locale
- the Locale, null for no localizationformat
- a format stringargs
- the arguments to format
-
displayFormat
Display formatted text with a title using the default locale. The title is used as the title of a dialog box when a dialog box is used to display the message, IfsetComponent
was not called, the title will be ignored and the message will appear on the*Appendable
used to log messages. SeeFormatter
for a description of the format string.- Parameters:
title
- the title; null for the default titleformat
- a format stringargs
- the arguments to format
-
displayFormat
Display formatted text with a title for a specific locale. The title is used as the title of a dialog box when a dialog box is used to display the message, If no component was specified for centering a dialog box, the title is ignored and the message is printed on anAppendable
. SeeFormatter
for a description of the format string.- Parameters:
title
- the title; null for the default titlelocale
- the Locale, null for no localizationformat
- a format stringargs
- the arguments to format
-
display
Display a message with a title. The title is used as the title of a dialog box when a dialog box is used to display the message. IfsetComponent
was not called,the title will be ignored and the message will appear on theAppendable
used to log messages.- Parameters:
msg
- the message to displaytitle
- the title; null for the default title- See Also:
-