[open-ils-commits] r14040 - trunk/Open-ILS/src/perlmods/OpenILS/WWW (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Sep 17 12:02:07 EDT 2009


Author: miker
Date: 2009-09-17 12:02:04 -0400 (Thu, 17 Sep 2009)
New Revision: 14040

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
Log:
use try/catch instead of eval/$@

Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm	2009-09-17 15:50:50 UTC (rev 14039)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm	2009-09-17 16:02:04 UTC (rev 14040)
@@ -6,6 +6,7 @@
 use File::stat;
 use Apache2::Const -compile => qw(OK DECLINED HTTP_INTERNAL_SERVER_ERROR);
 use Apache2::Log;
+use OpenSRF::EX qw(:try);
 
 use constant OILS_HTTP_COOKIE_SKIN => 'oils:skin';
 use constant OILS_HTTP_COOKIE_THEME => 'oils:theme';
@@ -56,20 +57,22 @@
     my $ctx = shift;
     my $data = shift;
 
-    eval { 
+    my $success = 0;
+
+    try { 
         my $doc = XML::LibXML->new->parse_string($data); 
         $data = $doc->documentElement->toStringC14N;
         $data = $ctx->{final_dtd} . "\n" . $data;
-    };
-
-    if($@) {
-        my $err = "Invalid XML: $@";
+        $success = 1;
+    } otherwise {
+	my $e = shift;
+        my $err = "Invalid XML: $e";
         $r->log->error($err);
         $r->content_type('text/plain; encoding=utf8');
         $r->print("\n$err\n\n$data");
-    } else {
-        $r->print($data);
-    }
+    };
+
+    $r->print($data) if ($success);
 }
 
 



More information about the open-ils-commits mailing list