use try/catch instead of eval/$@
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Sep 2009 16:02:04 +0000 (16:02 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Sep 2009 16:02:04 +0000 (16:02 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14040 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm

index 400203c..42eb6ff 100644 (file)
@@ -6,6 +6,7 @@ use XML::LibXML;
 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 @@ sub parse_as_xml {
     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);
 }