[LON-CAPA-cvs] cvs: loncom /homework daxeopen.pm

raeburn raeburn at source.lon-capa.org
Wed Aug 23 18:21:05 EDT 2023


raeburn		Wed Aug 23 22:21:05 2023 EDT

  Modified files:              
    /loncom/homework	daxeopen.pm 
  Log:
  - Coding style: avoid use of die within mod_perl.
  
  
Index: loncom/homework/daxeopen.pm
diff -u loncom/homework/daxeopen.pm:1.8 loncom/homework/daxeopen.pm:1.9
--- loncom/homework/daxeopen.pm:1.8	Wed Aug 23 20:39:06 2023
+++ loncom/homework/daxeopen.pm	Wed Aug 23 22:21:05 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Opening converted problems and directory listings for Daxe
 #
-# $Id: daxeopen.pm,v 1.8 2023/08/23 20:39:06 raeburn Exp $
+# $Id: daxeopen.pm,v 1.9 2023/08/23 22:21:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -201,9 +201,16 @@
             return OK;
         }
         $dirpath =~ s{/$}{};
-        opendir my $dir, $dirpath or die "Cannot open directory: $dirpath";
-        my @files = readdir $dir;
-        closedir $dir;
+        my @files;
+        if (opendir(my $dir, $dirpath)) {
+            @files = readdir($dir);
+            closedir($dir);
+        } else {
+            $request->content_type('text/plain');
+            $request->print("Error opening directory: $dirpath");
+            $request->status(403);
+            return OK;
+        }
         my $dirname = $dirpath;
         $dirname =~ s{^.*/([^/]*)$}{$1};
         $res .= "<directory name=\"$dirname\">\n";




More information about the LON-CAPA-cvs mailing list