[LON-CAPA-cvs] cvs: loncom /xml run.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 28 Mar 2003 23:32:47 -0000


albertel		Fri Mar 28 18:32:47 2003 EDT

  Modified files:              
    /loncom/xml	run.pm 
  Log:
  - error messages generated by instructor scripts was being hidden
  
  
Index: loncom/xml/run.pm
diff -u loncom/xml/run.pm:1.33 loncom/xml/run.pm:1.34
--- loncom/xml/run.pm:1.33	Mon Mar 24 22:00:31 2003
+++ loncom/xml/run.pm	Fri Mar 28 18:32:46 2003
@@ -1,6 +1,6 @@
 package Apache::run;
 #
-# $Id: run.pm,v 1.33 2003/03/25 03:00:31 albertel Exp $
+# $Id: run.pm,v 1.34 2003/03/28 23:32:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,14 +47,16 @@
 	$Apache::run::timeout=1;
 	die("timeout");
     };
+    my $innererror;
     eval {
 	alarm(Apache->request->server->timeout);
 	$safeeval->reval('{'.$decls.';$_=<<\'EXPRESSION\';'."\n".$expression.
 			 "\n".'EXPRESSION'."\n".$EVALUATE_STRING.'}');
+	$innererror=$@;
 	alarm(0);
     };
     my $error=$@;
-    if ($error eq '' && !$Apache::run::timeout) {
+    if ($error eq '' && $innererror eq '' && !$Apache::run::timeout) {
 	$result = $safeeval->reval('return $_;');
 	chomp $result;
     } else {
@@ -62,9 +64,14 @@
 	    $error = 'Code ran too long. It ran for more than '.
 		Apache->request->server->timeout.' seconds';
 	}
-	&Apache::lonxml::error('substitution on <pre>'.$expression.
-			       '</pre> with <pre>'.$decls.
-			       '</pre> caused <pre>'.$error);
+	&Apache::lonxml::error('substitution on <pre>'.
+			       &HTML::Entities::encode($expression).
+			       '</pre> with <pre>'.
+			       &HTML::Entities::encode($decls).
+			       '</pre> caused <pre>'.
+			       &HTML::Entities::encode($error).' '.
+			       &HTML::Entities::encode($innererror).
+			       '</pre>');
     }
     return $result
 }
@@ -78,18 +85,22 @@
 	$Apache::run::timeout=1;
 	die("timeout");
     };
+    my $innererror;
     eval {
 	alarm(Apache->request->server->timeout);
 	@result=$safeeval->reval($code);
+	$innererror=$@;
 	alarm(0);
     };
     my $error=$@;
-    if (($Apache::run::timeout || $error ne '') && !$hideerrors) {
+    &Apache::lonxml::debug("run got $@");
+    if (($Apache::run::timeout || $error ne '' || $innererror ne '') && !$hideerrors) {
 	if ($Apache::run::timeout) {
 	    $error = 'Code ran too long. It ran for more than '.
 		Apache->request->server->timeout.' seconds';
 	}
-	&Apache::lonxml::error('<pre>'.&HTML::Entities::encode($error).
+	&Apache::lonxml::error('<pre>'.&HTML::Entities::encode($error).' '.
+			       &HTML::Entities::encode($innererror).
 			       '</pre> occured while running <pre>'.
 			       &HTML::Entities::encode($code).'</pre>');
     }