Re: SWI-Prolog : Constructing Exceptions
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 18 Sep 2006 07:12:46 GMT
On 2006-09-17, roschler <robert.oschler@xxxxxxxxx> wrote:
I've been reading the 5.6 reference manual about Exceptions. I want to
construct my own and throw them. I found the manual page on Signal
handling, but I'm still a little vague on where to find the error
helper functions. For example, in one of the stock PL files
distributed with SWI-Prolog there is this line:
throw(error(permission_error(write, index_file, Dir), _))
This is a stream permission error exception I believe. Where can I
find the list of "error()" predicates so I know how to construct my
error object; especially one that will work well with "print_message"?
In my case I'm reading information from a file with get0/1, and I
intend to throw an exception if the resulting string I'm building is
too long.
Several options:
* Check out the ISO Prolog standard which describes these terms.
* Check the source for print_message/2 in pl/boot/messages.pl.
* Find a goal from which you know it gives the desired message
and use ?- catch(Goal, Error, true).
Ideally, this should of course all be documented ...
--- Jan
.
- References:
- SWI-Prolog : Constructing Exceptions
- From: roschler
- SWI-Prolog : Constructing Exceptions
- Prev by Date: Re: socket programming
- Next by Date: Re: SWI-Prolog : Out Of Local Stack
- Previous by thread: SWI-Prolog : Constructing Exceptions
- Next by thread: Newbie Question: Reading older grammar rule code...
- Index(es):