Re: XML write crash
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 02/08/2014 10:49 PM, Alan Baljeu wrote: >>It is the inverse of the sgml/html/xml reading. library(sgml) defines >>the output. It only is a bit more flexible wrt. input types. > > I'm reading that file and not seeing an explanation of what > constitutes valid element content. Predating PlDoc, it is mostly documented separately. See http://www.swi-prolog.org/pldoc/doc_for?object=load_structure/3 >>> Anyway, it might be nice to put in a clearer message when write >>> fails, because it's a beast to try to discern which element, or >>> portion thereof, is the problem. > >>I replaced the assertion with a type error. > > Will that give context of what it was trying to write at the moment? > This matters with a large document containing a small error. It will do what type errors do: ERROR: xyx expected, found <Term> You can use library(prolog_stack) to ask the system to dump a stack trace with the error. I have this in my ~/.plrc (pl.ini) to get a stack trace in the terminal on any uncaught exception: :- load_files(library(prolog_stack), [silent(true)]). prolog_stack:stack_guard(none). That is sometimes a bit noisy. Often it avoids having to use a debugger. The library provides several options to control how much information it gathers and when it comes to action to extend exceptions with stack information. Gathering the stack can be costly, so don't enable it for exceptions that are part of the normal control flow of your program! Cheers --- Jan