create error_404 action and switch default to use it
[catagits/catbook-code.git] / lib / LolCatalyst / Lite / Controller / Root.pm
index 395e4a9..9d6c5f2 100644 (file)
@@ -12,11 +12,16 @@ sub index :Path :Args(0) {
 
 sub default :Path {
     my ( $self, $c ) = @_;
+    $c->detach('/error_404');
+}
+
+sub error_404 :Private {
+    my ( $self, $c ) = @_;
     $c->response->status(404);
     $c->response->body( 'Page not found' );
 }
 
-sub translate :Local {
+sub translate :Private {
      my ($self, $c) = @_;
      my $lol = $c->req->body_params->{lol}; # only for a POST request
          # $c->req->params->{lol} would catch GET or POST
@@ -38,6 +43,8 @@ sub end : ActionClass('RenderView') {
     my ($self, $c) = @_;
     my $errors = scalar @{$c->error};
     if ($errors) {
+        $c->log->error("Errors in ${\$c->action}:");
+        $c->log->error($_) for @{$c->error};
         $c->res->status(500);
         $c->res->body('internal server error');
         $c->clear_errors;