Say in my controller I'm 5 levels deep and discover there is a problem with
the user's input. I call:

        template => 'errors/badValues',
        message => 'The value of foo cannot be "bar"',

And now I want to stop the entire request right there. I guess the
behaviour I'm looking for is that of an exception - return up the call
stack - without having to do something with a return value and then

      or return;

at every stack level. So what I've done is create an exception type and

        template => 'errors/badValues',
        message => 'The value of foo cannot be "bar"',

And then in setup:

    $self->hook( around_dispatch => sub {
        my ( $next, $c ) = @_;
        eval {
        if ($@) {
            my $err = $@;
            if (blessed($err) && $err->isa('StopRenderingException')) {
            } else {
                die $err;

It does have a hacky smell to it though. Is there a better best-practice?


You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to