From e9b4cd5fc79ca2d044eba4fed8bf62b138f44249 Mon Sep 17 00:00:00 2001 From: Darkelarious Date: Tue, 19 Jul 2022 18:28:00 +0200 Subject: simplify address format --- lib/MasterWebInterface/Handler/ErrorPages.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/MasterWebInterface/Handler/ErrorPages.pm') 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 => ''); -- cgit v1.2.3