Let's assume I have the following action in a Catalyst::Controller that requires the parameter bar to be present. If this parameter is not given in the query I want to show an error message:
sub foo : Local {
my ($self, $c) = @_;
if (!$c->req->params->{bar}) {
$c->stash->{error} = "Parameter 'bar' missing!";
$c->detach; # or return; ?
}
# some more logic...
}
Now my question is: does it make a difference whether I do $c->detach or simply return from the action? At first glance the behaviour seems to be identical, but are there any advantages or disadvantages of either option?