[ Event Handling | Reference Manual | Alphabetic Index ]

error_id(+N, -Message)

Succeeds if Message unifies with the error message string defined for error number N.
N
Positive integer.
Message
String or variable.

Description

This predicate unifies Message with the message string defined for error number N.

Modes and Determinism

Exceptions

(4) instantiation fault
N is not instantiated.
(5) type error
N is instantiated, but not to an integer.
(5) type error
Message is instantiated, but not to a string.

Examples

Success:
      error_id(80,M).
           (gives M="not a module").
      error_id(70,M).
           (gives M="accessing an undefined dynamic procedure").
      error_id(60,M).
           (gives M="accessing an undefined procedure").
      error_id(90,M).
           (gives M="declaration not at module beginning").

      ?- [user].
       warning_handler(X, Where) :-
              write('(warning) '),
              error_id(X, Message),
              write(Message),
              write(' in '),
              write(Where).
       user compiled 332 bytes in 0.05 seconds

      ?- warning_handler(60,dummy).
      (warning) accessing an undefined procedure in dummy
      yes.

      ?- [user].
       fail_warning(N, Where) :-
               write("Warning: Failure due to "),
               error_id(N, Errmsg),
               write(Errmsg),
               write(":"-Where),
               fail.
       user compiled 328 bytes in 0.00 seconds
      yes.

      ?- set_event_handler(68, fail_warning/2).
      yes.

      ?- p.
      Warning: Failure due to calling an undefined procedure: - p
      no.
Fail:
      error_id(60,"procedure not defined").
Error:
      error_id(N,"not a module").        (Error 4).
      error_id(1.0,M).                   (Error 5).
      error_id(1,atom).                  (Error 5).


See Also