Re: Extracting information from PL_exception()

Carlo Capelli <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CABty9wwbDCc8dLu6dADp01BZr1Ou22v_jF4gnk5xmwD7SKiHDA@mail.gmail.com>
Hi Kaitain

you can find some very useful code from SWI-cpp.h, where text extraction is
modelled by means of type cast operators.

class PlException : public PlTerm {
...
  operator const char *(void);
  operator const wchar_t *(void);
}

near bottom of file, you can spot the actual definition

__inline PlException::operator const wchar_t *(void)
{ PlFrame fr;
...
}





2014-03-01 4:01 GMT+01:00 Kaitain Jones <[email protected]>:

> I'm trying to work out what information I'm able to extract from calling
> PL_exception() from C after a call to PL_next_solution() has failed. I've
> set up a test case in which the underlying PL predicate will hit a
> guaranteed error due to it referencing another predicate that has not in
> fact been defined. So PL_next_solution() fails, as expected, and
> PL_exception() succeeds and returns a term_t term value. But what exactly
> is the value so returned (or, rather, the structure to which it is a
> handle)? I've ascertained that it is of type PL_TERM. (This is using the
> latest SWI on Windows, btw.) But it isn't a list or a string, and the most
> info I've been able to extract is by calling PL_get_name_arity(...), which
> tells me that it has name "error" and is of arity 2. But...is that it?
>
> In my simple console app the corresponding call sends the exception to the
> console:
>
> ERROR: test_predicate/1: Undefined procedure: nonsense_predicate/1
> Exception: (6) nonsense_predicate(test_object) ?
>
> Trying to integrate into our full-blown windows app, I don't get this kind
> of error message for free. I was hoping that the exception might give it to
> me, but I can't tell from the documentation whether I should expect to have
> access to this message, and if so how to extract it. Any pointers would be
> appreciated.
>
> KJ
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.