generate_message_hook/3 hook


:- multifile generate_message_hook/3.

generate_message_hook(+MessageTerm, -S0, -S)

A way for the user to override the call to 'QU_messages':generate_message/3 in print_message/2.


MessageTerm term
May be any term.
S0 list of pair
the resulting list of Control-Args pairs.
S list of pair
the remaining list.


For a given MessageTerm, generates the list of Control-Args pairs required for print_message_lines/3 to format the message for display.

This is the same as 'QU_messages':generate_message/3 except that it is a hook. It is intended to be used when you want to override particular messages from the Prolog system, or when you want to add some messages. If you are using your own exception classes (see raise_exception) it may be useful to provide generate_message_hook clauses for those exceptions so that the print_message/2 (and thus the default exception handler that calls print_message/2) can print them out nicely.

The Prolog system uses the built-in predicate print_message/2 to print all its messages. When print_message/2 is called, it calls


to generate the message. If that fails,


is called instead.

If generate_message_hook/3 succeeds, L is assumed to have been bound to a list whose elements are either Control-Args pairs or the atom nl. Each Control-Args pair should be such that the call

     format(user_error, Control, Args)

is valid. The atom nl is used for breaking the message into lines. Using the format specification ~n (new-line) is discouraged, since the routine that actually prints the message (see user:message_hook/3 and print_message_lines/3) may need to have control over newlines.

It is recommended that you declare this predicate multifile when you define clauses for it so that different packages that define clauses for it can be used together.



See also:

'QU_messages':generate_message/3, print_message/2, message_hook/3, format/[2,3], print_message_lines/3