common: treat exception references as alert parameters
[sheet.git] / common.inc.plp
index b8dac37ed30c9f043b50b9c6e5fa6fabaed83d82..71c5c1379f29aeb82d6d1211ec53dff69740d2cf 100644 (file)
@@ -47,10 +47,10 @@ BEGIN {
        our $Dev = $ENV{HTTP_HOST} =~ /\bdev\./;
 }
 
-our $Request = decode_utf8($ENV{PATH_INFO} =~ s{^/}{}r);
+our $Request //= decode_utf8($ENV{PATH_INFO} =~ s{^/}{}r);
 
 our $style;
-our $showkeys = !exists $get{keys} ? undef :
+our $showkeys //= !exists $get{keys} ? undef :
        ($get{keys} ne '0' && ($get{keys} || 'always'));
 
 $header{content_type} = 'text/html; charset=utf-8';
@@ -78,7 +78,7 @@ sub stylesheet {
 
        return map { sprintf(
                '<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
-               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.11", $_
+               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.13", $_
        ) } @avail;
 }
 
@@ -196,13 +196,20 @@ EOT
 
 BEGIN {
        $PLP::ERROR = sub {
-               my ($text, $html) = @_;
-               warn $text;
+               my ($message, $html) = @_;
+               if (ref $message) {
+                       warn join ': ', @{$message};
+                       $html = shift @{$message};
+               }
+               else {
+                       warn $message;
+                       $message = [];
+               }
                unless ($PLP::sentheaders) {
                        Html({nocache => 1});
                        say '<h1>Page unavailable</h1>';
                }
-               Alert("<strong>Fatal error</strong>: $html.");
+               Alert("Fatal error: $html.", @{$message});
        };
 }