Add traceback to help debug "Arguments are not sufficiently instantiated" error from functor/2 from bad markup#6
Add traceback to help debug "Arguments are not sufficiently instantiated" error from functor/2 from bad markup#6kamahen wants to merge 1 commit intoSWI-Prolog:masterfrom
Conversation
…ted" error from functor/2 from bad markup
| op(100, fx, #) | ||
| ]). | ||
| :- use_module(library(debug),[debug/3]). | ||
| :- use_module(library(prolog_stack)). % For catch_with_backtrace |
There was a problem hiding this comment.
The ordering of this use_module seems to be important.
| main(Argv) :- | ||
| catch_with_backtrace(main0(Argv), | ||
| Error, | ||
| ( set_prolog_flag(backtrace_goal_depth, 20), |
There was a problem hiding this comment.
These 2 set_prolog_flag calls didn't have the desired effect ... but I couldn't find another flag for setting the option for the write.
This is what I got when running from cmake:
ERROR: [2,630] tex:item_commands([_484|_486],[],[_490|_492]) at /home/peter/src/swipl-devel/build.debug/home/library/ext/ltx2htm/latex2html.pl:983
ERROR: [1,904] tex:items([\(classitem,...),'\n'|...],[[...|...]|_554]) at /home/peter/src/swipl-devel/build.debug/home/library/ext/ltx2htm/latex2html.pl:961
ERROR: [1,890] tex:env(description([],['\n'|...]),[html('<dl class="latex">'),_624|...]) at /home/peter/src/swipl-devel/build.debug/home/library/ext/ltx2htm/latex2html.pl:935
but when I ran it by hand (calling main0/1), and did the debugger u command, I got more useful information:
Exception: (1,887) tex:translate_env(description([], ['\n', \(classitem, [{'PlTerm'}]), '\n', 'Generic', 'Prolog', term|...]), file, file, _353630) ?
which helped me figure out where the bad markup was.
|
The catch_with_backtrace/3 is in any case not needed as that is already in main/0. I don't know whether it works properly. Adjusting the amount of information captured from the trace depends on the application and could be a good idea for this case. Although markup errors are better reported in some other way ... If you want to change these, you cannot do that in the exception handler. That is too late. The stack is assembled after detecting we want a backtrace (because of catch_with_backtrace/3 or the exception is unhandled) and before the stack is unwound and the handler is called. I think the way to go is that if there is a normal Prolog exception in the code, this needs to be debugged. In some cases temporary changing the stack printing is a way to find the issue. |
|
It appears that the Because I've fixed the underlying problem, I can't reproduce this error now. Anyway, this particular problem is at item_commands(List, [], List) :-
List = [Cmd|_],
functor(Cmd, \, _),
arg(1, Cmd, TexCmd),
tex_command_function(TexCmd, item),
!.so the call to So, does it make sense to at least add |
|
I see. It reproduces using this. Gets a nice backtrace with prolog_stack loaded and not without. I'm not sure where to change that though. I kind of dislike the Python approach to always print a backtrace. As a normal user of some app, it tends to be annoying. You can also get the desired effect after deleting the Possibly it does make sense for ltx2html to include it by default as it is not an end-user application anyway. |
|
https://www.swi-prolog.org/pldoc/man?predicate=catch_with_backtrace/3 says:
This use of Presumably, we should also set |
No description provided.