Arthur Axel "fREW" Schmidt > Catalyst-ActionRole-DetachOnDie-0.001005 > Catalyst::ActionRole::DetachOnDie



Annotate this POD

View/Report Bugs
Module Version: 0.001005   Source   Latest Release: Catalyst-ActionRole-DetachOnDie-0.001006


Catalyst::ActionRole::DetachOnDie - If something dies in a chain, stop the chain


version 0.001005


 package MyApp::Controller::Foo;
 use Moose;

 BEGIN { extends 'Catalyst::Controller::ActionRole' }

    action => {
       '*' => { Does => 'DetachOnDie' },



Chained dispatch is arguably one of the coolest features Catalyst has to offer, unfortunately it is marred by the bizarre decision to have exceptions thrown not detach a chain. To be clear, if one has a chain as follows:

 sub first  : Chained('/') PathPart('') CaptureArgs(0) { ... }
 sub middle : Chained('first') PathPart('middle') CaptureArgs(0) { ... }
 sub last   : Chained('middle') PathPart('') Args(0) { ... }

If the URL /middle is dispatched to, but an exception is raised in the middle (or even first) method, the last method will still run! This module solves that problem. I recommend you use it as I have documented in the "SYNOPSIS", as that will make it apply to all of your actions, but if for some reason you do not want to apply it to all actions you can apply it per action as follows:

 sub foo : Chained('bar') PathPart('') CaptureArgs(0) Does('DetachOnDie') { ... }

If you do not want to use the action role, check out Catalyst::Action::DetachOnDie, which does the same thing but does not require the use of Catalyst::Controller::ActionRole.


Arthur Axel "fREW" Schmidt <>


This software is copyright (c) 2012 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: