On Mon, Apr 24, 2017 at 12:33 PM, iaw4 <[email protected]> wrote:
> I think the exception object you are mentioning is the M way to do this?
Yes, also, I don't think you want your Mojolicious application to die() or
exit();
This seems perfectly reasonable to me:
sub urlrequest { callme( ); }
sub callme { calldeeper( ); }
sub calldeeper { ($somethingbadhashappened) and completelyredirect( ); }
sub completelyredirect { $c->flash( message => "you are too young to die" );
$c->redirect_to("/respawn/restart"); }
Whether you choose to use redirect_to() or reply->exception() is entirely
up to. You may not want a 500 status returned to your browser, you may
wish your web app to handle the error more gracefully.
However, rather than completelyredirect() setting flash() and redirect_to()
directly, I would probably have that sub return the message and the route
and then let the controller (urlrequest) handle accordingly:
sub urlrequest {
my $c = shift;
if ( my $x = callme() ) {
return $c->flash(message=>$x->{message})->redirect_to($x->{route});
}
...do more with $x...
}
Hope that makes sense and helps!
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.