Validad::Tools::Plack::Middleware::Error
file: code/Validad::Tools::Plack::Middleware::Error 51: $log->error( $req->uri->as_string . ': ' . $error ); 52: my $res = Plack::Response->new($status); 53: if ( 54: ( exists $env->{HTTP_X_REQUESTED_WITH} 55: && $env->{HTTP_X_REQUESTED_WITH} eq 'XMLHttpRequest' 56: ) 57: || ( exists $env->{HTTP_ACCEPT} 58: && $env->{HTTP_ACCEPT} =~ m{application/json}i ) 59: ) { 60: $res->content_type('application/json'); 61: $res->body( 62: encode_json( { status => 'error', message => "" . $error } ) ); 63: } 64: else { 65: $res->content_type('text/html'); 66: my $content = $self->rendered_error_page( $status, $error ); 67: $res->body($content); 68: } 69: return $res->finalize;
else return some nice HTML error page