-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
catch errors / warnings on consult #105
Comments
Hi yochem, I have a the same issue. I need to get an exception when there is an error in a consulted file. After some investigation, I think the problem lies in SWI prolog itself. SWI Prolog doesn't raise an exception when there is a mistake in the consulted file and hence, pyswip cannot raise any exception neither. I'm not sure about the rationale behind this behavior. But one explanation is that even when a prolog file contains errors, it is still "successfully" consulted up to the point where the first error occurs. I.e., all clauses preceding the one containing errors is still successfully added to the DB and you can use them. In any case, I guess that you would have to ask the SWI prolog team directly to throw an exception when there is an error in a consulted file. Once this is implemented on the SWI prolog side, I would assume that this excecption is also automatically raised on the pyswip side. Please be aware that everything I said above is my own conclusion after experimenting with SWI Prolog and pyswip and I don't know all the technical details. Hence, my conclusions could be wrong. |
Is it still same if you switch the catch_exception parameter? |
pyswip doesn't seem to recognise that parameter: >>> import pyswip
>>> pl = pyswip.Prolog()
>>> pl.consult('test.pl', catch_exception=True)
TypeError: consult() got an unexpected keyword argument 'catch_exception'
>>> pl.consult('test.pl', catchexception=True)
TypeError: consult() got an unexpected keyword argument 'catchexception'
>>> pl.consult('test.pl', catch_exceptions=True)
TypeError: consult() got an unexpected keyword argument 'catch_exceptions'
>>> pl.consult('test.pl', catchexceptions=True)
TypeError: consult() got an unexpected keyword argument 'catchexceptions' |
Dear maintainer(s),
I am using your package for automating grading of students' homework. The basic procedure is like this:
However, sometimes the students have errors or warnings on consulting. This should be catched by our program which can give feedback about this. Unfortunately I can't get this to work. I tried using the
catcherrors
parameter of the consult method, but that doesn't change anything. The warnings / errors are printed to stderr.Do you know if this would be possible? I would love something like returning it from the consult method or something like that.
The text was updated successfully, but these errors were encountered: