Quellcode durchsuchen

Make failure to read PageHead/PageFoot files non-fatal

Christoph Berg vor 21 Jahren
Ursprung
Commit
8e1134dfb3
2 geänderte Dateien mit 9 neuen und 2 gelöschten Zeilen
  1. 1 0
      docs/Changelog
  2. 8 2
      modules/Pisg/HTMLGenerator.pm

+ 1 - 0
docs/Changelog

@@ -16,6 +16,7 @@ pisg (0.64) - ??
      LogDirs.
    * No "Userpic" headline was shown when there were only DefaultPics.
    * Make "most used words" case-insensitive.
+   * Make failure to read PageHead/PageFoot files non-fatal.
    * Applied patch by Hanno Hecker to keep only the last 50 quotes for each
      nick while parsing. Saves memory and is probably saner anyway (thanks!).
    * Add version number to documentation title (and let the release Makefile

+ 8 - 2
modules/Pisg/HTMLGenerator.pm

@@ -344,7 +344,10 @@ HTML
 sub _pageheader
 {
     my $self = shift;
-    open(PAGEHEAD, $self->{cfg}->{pagehead}) or die("$0: Unable to open $self->{cfg}->{pagehead} for reading: $!\n");
+    unless(open(PAGEHEAD, $self->{cfg}->{pagehead})) {
+        warn("$0: Unable to open $self->{cfg}->{pagehead} for reading: $!\n");
+        return;
+    }
     while (<PAGEHEAD>) {
         _html($_);
     }
@@ -354,7 +357,10 @@ sub _pageheader
 sub _pagefooter
 {
     my $self = shift;
-    open(PAGEFOOT, $self->{cfg}->{pagefoot}) or die("$0: Unable to open $self->{cfg}->{pagefoot} for reading: $!\n");
+    unless(open(PAGEFOOT, $self->{cfg}->{pagefoot})) {
+        warn("$0: Unable to open $self->{cfg}->{pagefoot} for reading: $!\n");
+        return;
+    }
     while (<PAGEFOOT>) {
         _html($_);
     }