--- loncom/xml/run.pm	2003/03/24 22:43:31	1.32
+++ loncom/xml/run.pm	2003/04/03 14:35:59	1.35
@@ -1,6 +1,6 @@
 package Apache::run;
 #
-# $Id: run.pm,v 1.32 2003/03/24 22:43:31 albertel Exp $
+# $Id: run.pm,v 1.35 2003/04/03 14:35:59 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -45,16 +45,18 @@ sub evaluate {
     $Apache::run::timeout=0;
     $main::SIG{'ALRM'} = sub {
 	$Apache::run::timeout=1;
-	Apache->request->print("timeout<br /> \n");
+	die("timeout");
     };
+    my $innererror;
     eval {
-	alarm(Apache->request->server->timeout);
+	alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
 	$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 @@ sub evaluate {
 	    $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
 }
@@ -76,20 +83,24 @@ sub run {
     $Apache::run::timeout=0;
     $main::SIG{'ALRM'} = sub {
 	$Apache::run::timeout=1;
-	Apache->request->print("timeout<br /> \n");
+	die("timeout");
     };
+    my $innererror;
     eval {
-	alarm(Apache->request->server->timeout);
+	alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
 	@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>');
     }