X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/3565beca174066a12d2d952d4b24d79a0ca55412..756d5de12d15296e7689a7c5c7b5e35bd0bccb0e:/PLP.pm diff --git a/PLP.pm b/PLP.pm index ad4a227..52fba51 100644 --- a/PLP.pm +++ b/PLP.pm @@ -2,7 +2,7 @@ package PLP; # Not to be used without the CGI script; -our $VERSION = '3.03'; +our $VERSION = '3.04'; use PLP::Functions (); use PLP::Fields; @@ -101,10 +101,11 @@ sub source { sub error { my ($error, $type) = @_; if (not defined $type or $type < 100) { + return undef unless $PLP::DEBUG & 1; + my $plain = $error; + (my $html = $plain) =~ s/([<&>])/'&#' . ord($1) . ';'/ge; PLP::sendheaders unless $PLP::sentheaders; - $error =~ s/([<&>])/'&#' . ord($1) . ';'/ge; - print qq{
}, - qq{Debug information:
$error
}; + $PLP::ERROR->($plain, $html); } else { select STDOUT; my ($short, $long) = @{ +{ @@ -118,6 +119,12 @@ sub error { } } +sub _default_error { + my ($plain, $html) = @_; + print qq{
}, + qq{Debug information:
$html
}; +} + sub start { my $file = $ENV{PATH_TRANSLATED}; $ENV{PLP_NAME} = $ENV{PATH_INFO}; @@ -166,8 +173,10 @@ sub start { chdir $dir; $PLP::code = PLP::source($file, 0); + tie *PLPOUT, 'PLP::Tie::Print'; select PLPOUT; + $PLP::ERROR = \&_default_error; } 1;