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).