Open ghost opened 4 years ago
Here is an example of using the prolog:error_message//1 hook:
prolog:error_message(type_error(class_name_or_descriptor, Actual)) -->
['object, classname, descriptor or type expected, found `~p'''-[Actual]].
Which then gives me:
?- throw(error(type_error(class_name_or_descriptor,X),_)).
ERROR: object, classname, descriptor or type expected, found `_30228'
Hi @jburse . This seems to follow something else as you started with "Also..."
I am a bit lost of what this is about. Is the file you are linking from an old SWI version? I cannot find message.pl
package or none of the predicates you mention. See the current doc:
https://www.swi-prolog.org/pldoc/man?section=printmsg
There are no matches for, for example, `error_message/1':
https://www.swi-prolog.org/search?for=error_message
Can you elaborate more?
The link works on my side. Try following the link from GitHub page, not from notification E-mail, since I edited the link once. You should see:
Ohh I see, yes. I found the file under /usr/lib/swi-prolog/boot/messages.pl
, which is part of the SWI booting infrastructure.
There is not much documentation in SWIPL manual, if anything.
If I understand correctly, what you are suggesting is to improve the way that JPL throws exceptions, and instead of just putting the error in the text of the exception, build a set of structured errors (e.g., yours class_name_or_descriptor
) and then use error_message/1
to give "semantics" (its proper text message) to each formal error?
Is this what you are proposing/suggesting? If so, it does make sense, would be nice indeed.
Now, seems you are talking about exceptions on the Prolog side, when Prolog calls JPL? There is another pack of exceptions on the Java side.
There is not much documentation in SWIPL manual, if anything.
True. There is this tutorial: http://www.pathwayslms.com/swipltuts/message/index.html
If so, it does make sense, would be nice indeed.
I think that is the way to go. The PR by @dtonhofer works in that direction, but I don't think it introduces new types and domains, but instead (still) explains this using the comment arguments.
Great @JanWielemaker , thanks for that pointer, I think that should help a lot.
Now that I am finished with Dictionaries and Maven work, both work perfectly, I will look at that with @dtonhofer.
Also there is something strange that JPL doesn’t extend term_message//1. It has all the text directly inside the throw. But I guess the idea is that there is a message infrastructure that translates formal errors to text.
Maybe JPL could extend prolog:error_message//1. Don’t know what the official hook is. prolog:error_message//1 is probed by term_message//1, but prolog:error_message//1 is not further documented.
See also: https://www.swi-prolog.org/pldoc/doc/_SWI_/boot/messages.pl?show=src#term_message//1