aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterWebInterface/Handler/ErrorPages.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MasterWebInterface/Handler/ErrorPages.pm')
-rwxr-xr-xlib/MasterWebInterface/Handler/ErrorPages.pm27
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 => '');