This queue is for tickets about the XML-LibXSLT CPAN distribution.

Report information
The Basics
Id:
20903
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
dom [...] happygiraffe.net
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
1.58
Fixed in:
(no value)

Attachments


Subject: Better Error Messages for libxslt
I think it would be a good idea to apply the patch at <http://ahinea.wordpress.com/ 2006/07/14/libxslt-error-reporting-fix/> in order to improve the error reporting capabilities. I frequently get errors where I get no useful info at all... I've attached the patch in case the web site is down. -Dom
Subject: xml-libxslterror-reporting-patch.txt
*** XML-LibXSLT-1.58/LibXSLT.xs 2005-08-05 16:31:54.000000000 +0300 --- XML-LibXSLT-1.58-fixed-libxslt1.1.17-ivan-local/LibXSLT.xs 2006-07-08 11:00:52.000000000 +0300 *************** *** 20,23 **** --- 20,24 ---- #include <libxml/tree.h> #include <libxml/parser.h> + #include <libxml/globals.h> #include <libxml/parserInternals.h> #include <libxml/xpathInternals.h> *************** *** 31,34 **** --- 32,50 ---- #endif + /*** Error handling ***/ + + static xmlGenericErrorFunc xmlGenericError_original; + static void* xmlGenericErrorContext_original; + + #define SET_ERROR_HANDLERS() \ + xsltSetGenericErrorFunc(NULL, (xmlGenericErrorFunc)LibXSLT_error_handler); \ + xmlGenericError_original = xmlGenericError; \ + xmlGenericErrorContext_original = xmlGenericErrorContext; \ + xmlSetGenericErrorFunc(NULL, (xmlGenericErrorFunc)LibXSLT_error_handler); + + #define RESTORE_ERROR_HANDLERS() \ + xmlSetGenericErrorFunc(xmlGenericErrorContext_original, (xmlGenericErrorFunc)xmlGenericError_original); + + #define SET_CB(cb, fld) \ RETVAL = cb ? newSVsv(cb) : &PL_sv_undef;\ *************** *** 696,700 **** --- 712,720 ---- xsltSetGenericDebugFunc(NULL, NULL); } + + SET_ERROR_HANDLERS(); RETVAL = xsltParseStylesheetDoc(doc_copy); + RESTORE_ERROR_HANDLERS(); + if (SvTRUE(ERRSV)) { croak( SvPV_nolen(ERRSV) ); } /* *************** *** 727,731 **** --- 747,754 ---- xsltSetGenericDebugFunc(NULL, NULL); } + SET_ERROR_HANDLERS(); RETVAL = xsltParseStylesheetFile(filename); + RESTORE_ERROR_HANDLERS(); + if (SvTRUE(ERRSV)) { croak( SvPV_nolen(ERRSV) ); } /* *************** *** 789,793 **** --- 812,819 ---- (xmlInputReadCallback) LibXSLT_input_read, (xmlInputCloseCallback) LibXSLT_input_close); + + SET_ERROR_HANDLERS(); real_dom = xsltApplyStylesheet(self, doc, xslt_params); + RESTORE_ERROR_HANDLERS(); /* *************** *** 798,804 **** if (real_dom == NULL) { if (SvTRUE(ERRSV)) { ! croak("Exception occurred while applying stylesheet: %s", SvPV(ERRSV, len)); } - croak("Error applying stylesheet: %s", "(get error out of libxslt)"); } if (real_dom->type == XML_HTML_DOCUMENT_NODE) { --- 824,835 ---- if (real_dom == NULL) { if (SvTRUE(ERRSV)) { ! croak("Error while applying stylesheet: %s", SvPV_nolen(ERRSV)); ! } else { ! croak("Unknown error while applying stylesheet"); ! } ! } else { ! if (SvTRUE(ERRSV)) { ! warn( "Non-fatal errors while applying stylesheet: %s", SvPV_nolen(ERRSV) ); } } if (real_dom->type == XML_HTML_DOCUMENT_NODE) { *************** *** 845,854 **** xsltSetGenericDebugFunc(NULL, NULL); } real_dom = xsltApplyStylesheet(self, xmlParseFile(filename), xslt_params); if (real_dom == NULL) { if (SvTRUE(ERRSV)) { ! croak("Error applying stylesheet: %s", SvPV(ERRSV, len)); } - croak("Error applying stylesheet: %s", "(get error out of libxslt)"); } if (real_dom->type == XML_HTML_DOCUMENT_NODE) { --- 876,892 ---- xsltSetGenericDebugFunc(NULL, NULL); } + SET_ERROR_HANDLERS(); real_dom = xsltApplyStylesheet(self, xmlParseFile(filename), xslt_params); + RESTORE_ERROR_HANDLERS(); if (real_dom == NULL) { if (SvTRUE(ERRSV)) { ! croak("Error while applying stylesheet: %s", SvPV_nolen(ERRSV)); ! } else { ! croak("Unknown error while applying stylesheet"); ! } ! } else { ! if (SvTRUE(ERRSV)) { ! warn( "Non-fatal errors while applying stylesheet: %s", SvPV_nolen(ERRSV) ); } } if (real_dom->type == XML_HTML_DOCUMENT_NODE) {
On st 09.srp.2006 01:52:09, HDM wrote:
Show quoted text
> I think it would be a good idea to apply the patch at > <http://ahinea.wordpress.com/ > 2006/07/14/libxslt-error-reporting-fix/> in order to improve the
error
Show quoted text
> reporting capabilities. > I frequently get errors where I get no useful info at all... > > I've attached the patch in case the web site is down. > > -Dom
A very similar patch was recently applied on the SVN repository. To check out use e.g. svn co svn://axkit.org/XML-LibXSLT/trunk XML-LibXSLT It would be nice if you could look and see if the current SVN code suits your needs, so I can close this ticket. -- Petr
I'm closing this ticket. Feel free to reopen if you find the error reporting in the upcoming 1.60 release still insufficient.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.