[ ECLiPSe Event built-in.|Group Index| Full Index]

set_error_handler(+Number, +PredSpec)

Set an error handler PredSpec for the error with number Number.

+Number
Integer.
+PredSpec
Term of the form Atom/Integer.

Description

Assigns the procedure specified by PredSpec (specified as name/arity) as the error handler for the error whose number is given by Number.

An error handler such as PredSpec can have 3 optional arguments: the 1st argument is the number of the error; the 2nd argument is the culprit (a structure corresponding to the call which caused it); the 3rd is the caller module or a free variable (if the module is unknown). The error handler is free to use less than 3 arguments.

The errors which exist are implementation defined.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Either Number or PredSpec is not instantiated.
(5) Type error
Number is not an integer.
(5) Type error
PredSpec is not of the form Atom/Integer.
(6) Range error
Number is not a valid error number.
(6) Range error
PredSpec is of the form Atom/Integer, but the integer is greater than 3.
(60)
PredSpec is of the form Atom/Integer, but no such predicate has been defined.

Examples


Success:
      [eclipse]: string_list(S,L).
      instantiation fault in string_list(_g50, _g52)
      [eclipse]: get_error_handler(4,M,N).
      M = error_handler/2
      N = sepia_kernel
      yes.
      [eclipse]: set_error_handler(4,true/0), string_list(S,L).
      S = _g56
      L = _g58
      yes.

      [eclipse]: [user].
       a :- write(toplevel_output_, "typo"), fail.
       user compiled 100 bytes in 0.03 seconds
      [eclipse]: set_error_handler(5,a/0).
      yes.
      [eclipse]: atom_length("atom",L).
      typo
      no.

Error:
      set_error_handler(N,true/0).   (Error 4).
      set_error_handler(5,P).        (Error 4).
      set_error_handler(5.0,true/0). (Error 5).
      set_error_handler(1000,X).     (Error 6).
      set_error_handler(-1,X).       (Error 6).
      set_error_handler(6,a/4).      (Error 6).  % arity > 3.
      set_error_handler(6,t/2).      (Error 60). % no t/2.


See Also

get_error_handler / 3