Bug 38 - Can not catch an exception thrown within consult/1
: Can not catch an exception thrown within consult/1
Status: CONFIRMED
Product: SWI-Prolog
Classification: Unclassified
Component: core
: unspecified
: PC Windows
: Highest normal
Assigned To: Jan Wielemaker
:
:
:
  Show dependency treegraph
 
Reported: 2012-06-05 15:34 CEST by Holger Kanwischer
Modified: 2012-06-05 16:19 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Kanwischer 2012-06-05 15:34:04 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.
Comment 1 Jan Wielemaker 2012-06-05 16:19:18 CEST
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