user_errorallows 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 126.96.36.199. The following message kinds are known:
- The system banner message. Banner messages can be suppressed by setting
the Prolog flag verbose
- Message from library(debug). See debug/3.
- 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.4).
- User requested help message, for example after entering‘h' or‘?' to a prompt.
- Information that is requested by the user. An example is statistics/0.
- Typically messages of events are progres that are considered useful to a
developer. Such messages can be suppressed by setting the Prolog flag verbose
- Message that is normally not printed. Applications may define message_hook/3 to act upon such messages.
- Messages from the (command line) tracer.
- The message indicates something dubious that is not considered fatal. For example, discontiguous predicates (see discontiguous/1).
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.
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
for a deeper discussion and examples.
See also message_to_string/2.