next up previous contents index
Next: Handling signals Up: ISO compliant Exception handling Previous: The exception term   Contents   Index

Printing messages

The predicate print_message2 may be used to print a message term in a human readable format. The other predicates from this section allow the user to refine and extend the message system. The most common usage of print_message2 is to print error messages from exceptions. The code below prints errors encountered during the execution of Goal, without further propagating the exception and without starting the debugger.


\begin{code}
...,
catch(Goal, E,
( print_message(error, E),
fail
)),
...
\end{code}

Another common use is to defined message_hook3 for printing messages that are normally silent, suppressing messages, redirecting messages or make something happen in addition to printing the message.

print_message2+Kind, +Term The predicate print_message2 is used to print messages, notably from exceptions in a human-readable format. Kind is one of informational, warning, error, help or silent. A human-readable message is printed to the stream user_error.

This predicate first translates the Term into a list of `message lines' (see print_message_lines3 for details). Next it will call the hook message_hook3 to allow the user intercepting the message. If message_hook3 fails it will print the message unless Kind is silent.

The print_message2 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.

See also message_to_string2.

print_message_lines3+Stream, +Prefix, +Lines Print a message (see print_message2) that has been translated to a list of message elements. The elements of this list are:

Format-Args Where Format is an atom and Args is a list of format argument. Handed to format3. flush If this appears as the last element, Stream is flushed (see flush_output1) and no final newline is generated. at_same_line If this appears as first element, no prefix is printed for the first line and the line-position is not forced to 0 (see format1, ~N). Format Handed to format3 as format(Stream, Format, []). nl A new line is started and if the message is not complete the Prefix is printed too.

See also print_message2 and message_hook3.

message_hook3+Term, +Kind, +Lines Hook predicate that may be define in the module user to intercept messages from print_message2. Term and Kind are the same as passed to print_message2. Lines is a list of format statements as described with print_message_lines3. See also message_to_string2.

This predicate should be defined dynamic and multifile to allow other modules defining clauses for it too.

message_to_string2+Term, -String Translates a message-term into a string object (see string. Primarily intended to write messages to Windows in XPCE (see xpce) or other GUI environments.


next up previous contents index
Next: Handling signals Up: ISO compliant Exception handling Previous: The exception term   Contents   Index
Dr. Richard Botting 2001-12-12