From 4ab2e7ca1e52f49401f2118cacef347b3babd63e Mon Sep 17 00:00:00 2001 From: David Baird Date: Mon, 3 Oct 2005 11:47:00 +0000 Subject: [PATCH] Refactored handler_guts - put view processing in a separate call. Planning to move the call to handler(), after calling handler_guts(), but that breaks tests at the moment. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@383 48953598-375a-da11-a14b-00016c27c3ee --- lib/Maypole.pm | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/Maypole.pm b/lib/Maypole.pm index e9aec84..73c9e75 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -159,25 +159,33 @@ sub handler_guts } } - if ( !$r->output ) - { # You might want to do it yourself - eval { $status = $r->view_object->process($r) }; + # unusual path - perhaps output has been set to an error message + return OK if $r->output; + + # normal path - no output has been generated yet + return $r->__call_process_view; +} + +sub __call_process_view +{ + my ($r) = @_; + + my $status; + + eval { $status = $r->view_object->process($r) }; + + if ( my $error = $@ ) + { + $status = $r->call_exception($error); - if ( my $error = $@ ) + if ( $status != OK ) { - $status = $r->call_exception($error); - - if ( $status != OK ) - { - warn "caught view error: $error" if $r->debug; - return $r->debug ? $r->view_object->error($r, $error) : ERROR; - } + warn "caught view error: $error" if $r->debug; + return $r->debug ? $r->view_object->error($r, $error) : ERROR; } - - return $status; } - return OK; + return $status; } sub __load_model -- 2.39.5