Subject: | Patch: more useful error message on parse error |
Currently some of the messages you get parsing are not useful.
e.g.
# No such file or directory at /usr/lib64/perl5/vendor_perl/XML/Parser/Expat.pm line 470.
Which file?
With the patch below:
# No such file or directory at /usr/lib64/perl5/vendor_perl/XML/Parser/Expat.pm line 470.
# at line 7:
# %DOCBOOK_ENTS;
# <!ENTITY % BOOK_ENTITIES SYSTEM "Test_DB5_Book.ent">
# %BOOK_ENTITIES;
# ^
# ]>
# <info version="5.0" xml:lang="en-US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
Oh it can't find one of the files referenced in the XML header, that is more useful information.
############ start patch ############
diff -ur a/Expat.pm b/Expat.pm
--- a/Expat.pm 2014-09-24 12:28:05.046517986 +1000
+++ b/Expat.pm 2014-09-24 12:28:53.637728671 +1000
@@ -466,7 +466,12 @@
$prev_rs = $ioclass->input_record_separator("\n$delim\n")
if defined($delim);
- $result = ParseStream($parser, $ioref, $delim);
+ eval {
+ $result = ParseStream($parser, $ioref, $delim);
+ };
+ if($@) {
+ $self->xpcroak("$@");
+ }
$ioclass->input_record_separator($prev_rs)
if defined($delim);
############ end patch ############