You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2001/07/10 01:15:41 UTC
cvs commit: xml-xerces/perl/Handler PerlExceptionHandler.cpp
jasons 01/07/09 16:15:41
Modified: perl/Handler PerlExceptionHandler.cpp
Log:
* Handler/PerlExceptionHandler.cpp (Repository):
Now handles IDOM_DOMExceptions
SAXException messages now get transcoded when there is no handler
Revision Changes Path
1.3 +60 -2 xml-xerces/perl/Handler/PerlExceptionHandler.cpp
Index: PerlExceptionHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/perl/Handler/PerlExceptionHandler.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PerlExceptionHandler.cpp 2001/07/09 17:21:39 1.2
+++ PerlExceptionHandler.cpp 2001/07/09 23:15:39 1.3
@@ -4,6 +4,7 @@
#include "util/XMLString.hpp"
#include "util/XMLException.hpp"
#include "dom/DOM_DOMException.hpp"
+#include "idom/IDOM_DOMException.hpp"
#include "sax/SAXException.hpp"
// initialize the static instance pointer
@@ -12,6 +13,7 @@
PerlExceptionHandler::PerlExceptionHandler() {
// we initialize the exceptionHandler
XMLExceptionHandler = NULL;
+ IDOMExceptionHandler = NULL;
DOMExceptionHandler = NULL;
SAXNotRecognizedExceptionHandler = NULL;
SAXNotSupportedExceptionHandler = NULL;
@@ -22,6 +24,10 @@
SvREFCNT_dec(XMLExceptionHandler);
XMLExceptionHandler = NULL;
}
+ if (IDOMExceptionHandler != NULL) {
+ SvREFCNT_dec(IDOMExceptionHandler);
+ IDOMExceptionHandler = NULL;
+ }
if (DOMExceptionHandler != NULL) {
SvREFCNT_dec(DOMExceptionHandler);
DOMExceptionHandler = NULL;
@@ -79,6 +85,23 @@
}
SV *
+PerlExceptionHandler::setIDOMExceptionHandler(SV *codeRef) {
+ SV *oldRef = &PL_sv_undef; // default to 'undef'
+ if (SvTYPE( SvRV(codeRef)) == SVt_PVCV) {
+ if (IDOMExceptionHandler != NULL) {
+ oldRef = IDOMExceptionHandler;
+ SvREFCNT_dec(oldRef);
+ }
+ SvREFCNT_inc(codeRef);
+ IDOMExceptionHandler = codeRef;
+ } else {
+ cerr << "\nsetIDOMExceptionHandler: "
+ << "invalid argument, must be code reference.\n" << endl;
+ }
+ return oldRef;
+}
+
+SV *
PerlExceptionHandler::setSAXNotRecognizedExceptionHandler(SV *codeRef) {
SV *oldRef = &PL_sv_undef; // default to 'undef'
if (SvTYPE( SvRV(codeRef)) == SVt_PVCV) {
@@ -183,11 +206,46 @@
}
void
+PerlExceptionHandler::catchIDOMException(const IDOM_DOMException &e) {
+ if (!IDOMExceptionHandler) {
+ cerr << "\nReceived IDOMException without handler" << endl
+ << "Exception code is: " << endl
+ << e.code << endl
+ << "Exception message is: " << endl
+ << XMLString::transcode(e.msg) << endl << endl;
+ XMLPlatformUtils::Terminate();
+ die("Received Exception without handler");
+ }
+ dSP;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+
+ // first argument is the element name
+ char *class_name = "XML::Xerces::IDOM_DOMException";
+ HV *hash = newHV();
+ HV *stash = gv_stashpv(class_name, FALSE);
+ hv_magic(hash,
+ (GV *)sv_setref_pv(sv_newmortal(),
+ class_name, (void *)&e),
+ 'P');
+ XPUSHs(sv_bless(newRV_noinc((SV *)hash), stash));
+ PUTBACK;
+
+ perl_call_sv(IDOMExceptionHandler, G_VOID);
+
+ FREETMPS;
+ LEAVE;
+}
+
+void
PerlExceptionHandler::catchSAXNotRecognizedException(const SAXNotRecognizedException &e) {
if (!SAXNotRecognizedExceptionHandler) {
cerr << "\nReceived SAXNotRecognizedException without handler" << endl
<< "Exception message is: " << endl
- << e.getMessage() << endl << endl;
+ << XMLString::transcode(e.getMessage()) << endl << endl;
XMLPlatformUtils::Terminate();
die("Received Exception without handler");
}
@@ -220,7 +278,7 @@
if (!SAXNotSupportedExceptionHandler) {
cerr << "\nReceived SAXNotSupportedException without handler" << endl
<< "Exception message is: " << endl
- << e.getMessage() << endl << endl;
+ << XMLString::transcode(e.getMessage()) << endl << endl;
XMLPlatformUtils::Terminate();
die("Received Exception without handler");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org