common: common Alert function to format error messages
[sheet.git] / common.inc.plp
index 81f91b5bc8dbd285777083dabdd232fdd17bcc4d..e4cc5f99f5635a4920d007ddb5433878c13c991c 100644 (file)
@@ -10,9 +10,15 @@ use File::stat 'stat';
 use HTTP::Date;
 use Encode qw( decode_utf8 );
 
+sub Alert {
+       my ($title, $debug) = @_;
+       $title .= ": <em>$debug</em>" if $Dev and defined $debug;
+       say "<p class=error>$title</p>\n";
+}
+
 $PLP::ERROR = sub {
        my ($text, $html) = @_;
-       print '<p class="error"><strong>Fatal error</strong>: '.$html."</p>\n\n";
+       Alert("<strong>Fatal error</strong>: $html.");
        warn $text;
 };