user_error
allows displaying the message
appropriate to the application (terminal, logfile, graphics), acting on
messages based on their content instead of a string (see message_hook/3)
and creating language specific versions of the messages. See also
section 4.11.1. The
following message kinds are known:
- banner
- The system banner message. Banner messages can be suppressed by setting
the Prolog flag verbose
to
silent
. - debug(Topic)
- Message from library(debug). See debug/3.
- error
- The message indicates an erroneous situation. This kind is used to print
uncaught exceptions of type
error(Formal, Context)
. See section introduction (section 4.11). An error message causes the process to halt with status 1 if the Prolog flag on_error is set tohalt
and the message is not intercepted by message_hook/3. Not intercepted error messages increment theerrors
key for statistics/2. - help
- User requested help message, for example after entering‘h’or‘?’to a prompt.
- information
- Information that is requested by the user. An example is statistics/0.
- informational
- Typically messages of events and progress that are considered useful to
a developer. Such messages can be suppressed by setting the Prolog flag verbose
to
silent
. - silent
- Message that is normally not printed. Applications may define message_hook/3 to act upon such messages.
- trace
- Messages from the (command line) tracer.
- warning
- The message indicates something dubious that is not considered fatal.
For example, discontiguous predicates (see discontiguous/1).
A warning message causes the process to halt with status 1 if the Prolog
flag
on_warning is set
to
halt
and the message is not intercepted by message_hook/3. Not intercepted warning messages increment thewarnings
key for statistics/2.
The predicate print_message/2
first translates the Term into a list of‘message lines’(see print_message_lines/3
for details). Next, it calls the hook message_hook/3
to allow the user to intercept the message. If message_hook/3
fails it prints the message unless Kind is silent
.
The print_message/2
predicate and its rules are in the file
<plhome>/boot/messages.pl
, which may be
inspected for more information on the error messages and related error
terms. If you need to write messages from your own predicates, it is
recommended to reuse the existing message terms if applicable. If no
existing message term is applicable, invent a fairly unique term that
represents the event and define a rule for the multifile predicate
prolog:message//1. See
section 4.11.1 for a
deeper discussion and examples.
See also message_to_string/2.