Bugzilla – Bug 38
Can not catch an exception thrown within consult/1
Last modified: 2012-06-05 16:19:18 CEST
Windows XP 32-Bit With version 5.9.7: Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.9.7) ... 1 ?- catch(consult('dfdfdf'), T, true), write(T). error(existence_error(source_sink, dfdfdf), _G750) T = error(existence_error(source_sink, dfdfdf), _G750). With version 6.0.2: Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 6.0.2) ... 1 ?- catch(consult('dfdfdf'), T, true), write(T). ERROR: source_sink `dfdfdf' does not exist _G460 true.
Thanks. Fixed in the pl-devel.git sources. This was in part a deliberate change, avoiding to stop loading if one of the arguments of a list is not present. Now it throws an exception if the argument is not a list and merely prints an error otherwise. Work around is typically: :- if(exists_source(xxx)). :- consult(xxx). :- endif. Cheers --- Jan