chiark / gitweb /
mason/dhandler: Trap errors from module imports. master
authorMark Wooding <mdw@distorted.org.uk>
Tue, 24 Dec 2024 13:10:12 +0000 (13:10 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 24 Dec 2024 13:10:12 +0000 (13:10 +0000)
Notice errors from module imports by doing it the hard way in `eval',
and actually stop the process if there are problems.

mason/dhandler

index 8c151bac19ac249c4b629fc2283febd1b9ae0d4c..610a5440caa942789e5b99706afe464b5e7803ae 100755 (executable)
@@ -434,13 +434,19 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %
 %###-------------------------------------------------------------------------
 <%once>
-       use autodie;
-       use File::stat;
+       BEGIN {
+         eval {
+           require autodie; autodie->import;
+           require File::stat; File::stat->import;
 
-       use TrivGal;
+           require TrivGal; TrivGal->import;
+         };
+         if ($@) { print "$@"; exit 2; }
+       }
 </%once>
 %
 <%init>
+       clean_temp_files;
        TrivGal->init;
 
        my $path = $m->dhandler_arg;