]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole.pm
view exceptions and some code cleaning
[maypole.git] / lib / Maypole.pm
index 4a5a8e79cb82a5a982b150c0c599cf15a2ed74ed..4a5201127794ab8c8936cd322eeeb62de83395b1 100644 (file)
@@ -78,7 +78,15 @@ sub handler_guts {
     }
 
     # We authenticate every request, needed for proper session management
-    my $status = $r->call_authenticate;
+    my $status;
+    eval { $status = $r->call_authenticate };
+    if ( my $error = $@ ) {
+        $status = $r->call_exception($error);
+        if ( $status != OK ) {
+            warn "caught authenticate error: $error";
+            return $r->debug ? $r->view_object->error( $r, $error ) : ERROR;
+        }
+    }
     if ( $r->debug and $status != OK and $status != DECLINED ) {
         $r->view_object->error( $r,
             "Got unexpected status $status from calling authentication" );
@@ -98,7 +106,15 @@ sub handler_guts {
         }
     }
     if ( !$r->{output} ) {    # You might want to do it yourself
-        return $r->view_object->process($r);
+        eval { $status = $r->view_object->process($r) };
+        if ( my $error = $@ ) {
+            $status = $r->call_exception($error);
+            if ( $status != OK ) {
+                warn "caught view error: $error";
+                return $r->debug ? $r->view_object->error( $r, $error ) : ERROR;
+            }
+        }
+        return $status;
     }
     else { return OK; }
 }
@@ -324,7 +340,8 @@ Simon Cozens, C<simon@cpan.org>
 
 =head1 THANK YOU
 
-Jesse Scheidlower, Jody Belka, Markus Ramberg, Mickael Joanne, Simon Flack and all the others who've helped.
+Jesse Scheidlower, Jody Belka, Markus Ramberg, Mickael Joanne, Simon Flack,
+Veljko Vidovic and all the others who've helped.
 
 =head1 LICENSE