Subject: Debugging catched exceptions

From: Katzer Joachim <[email-masked]>
Date: Fri, 24 Mar 2000 17:32:09 +0100

Hi,

I'm using SWI-Prolog 3.3.4.
How can I trace/debug catched exceptions like in the following sample:

	a_predicate_causing_an_exception :- A is B.
	a_predicate :- a_predicate_causing_an_exception.
	main :-  catch(a_predicate, A, format(user_error, 'EXCEPTION: ~w~n',
A)).

If I call "a_predicate", the exception is catched by the tracer and I can
examine the call stack.

	?- trace, a_predicate.
	   Call: (8) a_predicate ? leap
	ERROR: Arguments are not sufficiently instantiated
	^  Exception: (10) _G300 is _G301 ? goals
	     [10] _G309 is _G310
	      [9] a_predicate_causing_an_exception
	      [8] a_predicate

But if I try to debug "main", the exception is handled by main and the trace
mode not entered:

	?- trace, main.
	   Call: (8) main ? leap
	EXCEPTION: error(instantiation_error, _G250)

Is there a possibility to configure SWI-Prolog that it enteres trace mode
when the exeption is raised - without replacing the catch statements in the
program?
Otherwise it is hard to locate bugs causing exceptions in larger Prolog
programs which use catch (and throw) statements extensively.

Regards

Joachim Katzer