added some error logging
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 16 May 2006 18:51:01 +0000 (18:51 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 16 May 2006 18:51:01 +0000 (18:51 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@717 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/Transport/SlimJabber/MessageWrapper.pm

index b792721..b337dff 100644 (file)
@@ -1,5 +1,7 @@
 package OpenSRF::Transport::SlimJabber::MessageWrapper;
 use XML::LibXML;
+use OpenSRF::EX qw/:try/;
+use OpenSRF::Utils::Logger qw/$logger/;
 
 sub new {
        my $class = shift;
@@ -9,7 +11,17 @@ sub new {
 
        my ($doc, $msg);
        if ($xml) {
-               $doc = XML::LibXML->new->parse_string($xml);
+               my $err;
+
+               try {
+                       $doc = XML::LibXML->new->parse_string($xml);
+               } catch Error with {
+                       $err = shift; 
+                       warn "MessageWrapper received bad XML : error = $err\nXML = $xml\n";
+                       $logger->error("MessageWrapper received bad XML : error = $err : XML = $xml");
+               };
+               throw $err if $err;
+
                $msg = $doc->documentElement;
        } else {
                $doc = XML::LibXML::Document->createDocument;