- priority: 5 --> 7
- assigned_to: nobody --> sfandino
Currently, prologDoc will exit on the first error. The following
changes to the prolog_doc.pl file, uses the catch mechanism
to handle errors, display them, and continue with the remaining
files in the list.
The first change is in prologDoc/3, replacing the line:
; read\_here:consult\(Load\) \),
with:
; \(write\('Consulting '\), write\(Load\), write\('...'\),
read_here:consult(Load), writeln('Done!')) ),
The second change is in run/4, replacing the lines:
writef\('Processing %t \(%t\)... ', \[Human, Path\]\), generateHTML\(DestDir, File, AllFiles, Links\), createLinks\(Links, File, LinksWithFileName\), writeln\('Done\!'\),
with:
catch\( \( \(writef\('Processing %t \(%t\)... ', \[Human, Path\]\), \( generateHTML\(DestDir, File, AllFiles, Links\) -> true ; writeln\('Failed in generateHTML.'\) \), \( createLinks\(Links, File, LinksWithFileName\) -> true ; writeln\('Failed in createLinks.'\) \) \) -> writeln\('Done\!'\) \), Exception, writef\('Failed with exception: %t \n',\[Exception\]\) \),
prologDoc(DestDir, Files, Load) :-
( Load = ''
-> true
; (write('Consulting '), write(Load), write('...'),
read_here:consult(Load), writeln('Done!')) ),
calculateFileProps(Files, Props),
sortFileProps(Props, SortedProps),
run(DestDir, SortedProps, SortedProps, Links),
indexFile(DestDir, SortedProps, Links).
run(_,[],_,[]) :- !.
run(DestDir, [File|FL], AllFiles, AllLinks) :-
fileHuman(File, Human),
filePath(File, Path),
catch(
( (writef('Processing %t (%t)... ', [Human, Path]),
( generateHTML(DestDir, File, AllFiles, Links)
-> true
; writeln('Failed in generateHTML.') ),
( createLinks(Links, File, LinksWithFileName)
-> true
; writeln('Failed in createLinks.') ) )
->
writeln('Done!') ),
Exception,
writef('Failed with exception: %t \n',[Exception]) ),
run(DestDir, FL, AllFiles, RestLinks),
append(LinksWithFileName, RestLinks, AllLinks).