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:
silent
.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 to
halt
and the message is not intercepted by message_hook/3.
Not intercepted error messages increment the errors
key for
statistics/2.silent
.halt
and the message is not intercepted by message_hook/3.
Not intercepted warning messages increment the warnings
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.