diff options
| author | Darkelarious <darkelarious@333networks.com> | 2022-07-19 18:28:00 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2022-07-19 18:28:00 +0200 |
| commit | e9b4cd5fc79ca2d044eba4fed8bf62b138f44249 (patch) | |
| tree | f396b20f3f415989529484eaacf12314dc72e019 /lib/MasterWebInterface/Handler/ErrorPages.pm | |
| parent | 30adff959ed724224d4a9e1d37b08705f5d62f53 (diff) | |
| download | WebInterface-Perl-e9b4cd5fc79ca2d044eba4fed8bf62b138f44249.tar.gz WebInterface-Perl-e9b4cd5fc79ca2d044eba4fed8bf62b138f44249.zip | |
simplify address format
Diffstat (limited to 'lib/MasterWebInterface/Handler/ErrorPages.pm')
| -rwxr-xr-x | lib/MasterWebInterface/Handler/ErrorPages.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/MasterWebInterface/Handler/ErrorPages.pm b/lib/MasterWebInterface/Handler/ErrorPages.pm index 7a74355..8c0b5e9 100755 --- a/lib/MasterWebInterface/Handler/ErrorPages.pm +++ b/lib/MasterWebInterface/Handler/ErrorPages.pm @@ -12,9 +12,22 @@ TUWF::register( qr{500} => sub {die "Process died on purpose, but with a lot of text to test if the whole error is correctly displayed on the screen when debug information is enabled in the website configuration, "}, ); +# +# 404 page or json status sub handle404 { my $self = shift; + + # json error status separately + if ( $self->reqPath() =~ m/^\/json/ig) + { + $self->resHeader("Content-Type", "application/json; charset=UTF-8"); + $self->resJSON({ + error => 1, + in => "url_format" + }); + return; + } $self->resStatus(404); $self->htmlHeader(title => '404 - Not Found'); @@ -37,10 +50,24 @@ sub handle404 $self->htmlFooter; } +# +# 500 page or json status sub handle500 { my($self, $error) = @_; + # json error status separately + if ( $self->reqPath() =~ m/^\/json/ig) + { + $self->resHeader("Content-Type", "application/json; charset=UTF-8"); + $self->resJSON({ + error => 1, + in => "internal_error", + internal => ( $self->debug ? $error : () ) + }); + return; + } + $self->resStatus(500); $self->htmlHeader(title => '500 - Internal Server Error'); $self->htmlSearchBox(title => "Servers", action => "/s", sel => 's', fq => ''); |
