11.3.162 print_message/2   hookable

Synopsis

print_message(+Severity, +MessageTerm)

Print a Message of a given Severity. The behavior can be customized using the hooks user:portray_message/2, user:generate_message_hook/3 and user:message_hook/3.

Arguments

Severity

atom, must be nonvar

Unless the default system portrayal is overidden with user:message_hook/3, Severity must be one of:

Value

Prefix

informational

%

warning

*

error

!

help
query
silent

no prefix

MessageTerm

term

Description

First print_message/2 calls user:portray_message/2 with the same arguments. If this does not succeed, then the message is processed in the following phases:

An unhandled exception message E calls print_message(error, E) before returning to the top level. The convention is that an error message is the result of an unhandled exception. Thus, an error message should only be printed if raise_exception/1 does not find a handler and unwinds to the top-level.

All messages from the system are printed using this predicate. Means of intercepting these messages before they are printed are provided.

print_message/2 always prints to user_error. Messages can be redirected to other streams using user:message_hook/3 and print_message_lines/3

Silent messages do not get translated or printed, but they can be intercepted with user:portray_message/2 and user:message_hook/3.

Exceptions

instantiation_error
type_error
domain_error

in Severity

See Also

ref-msg.



Send feedback on this subject.