An event handler which is used as an error handler can have 3 optional arguments: the 1st argument is the event number; 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.
Handlers for events raised by event/1 or posted to the system from the outside usually have no arguments or just the event name.
Events can be raised by
- one of the builtins event/1, error/2 or error/3. - posting an event from external code using ec_post_event(). - an interrupt whose handler has been specified as event/1.The latter two have the effect of dynamically inserting an event/1 goal into the current execution at the next synchronous point, which is usually just before the next predicate call.
Success: [eclipse 1]: event(hello). warning: no handler for event in hello yes. [eclipse 2]: set_event_handler(hello, writeln/1). yes. [eclipse 3]: event(hello). hello yes.