fREWdiculous!
23 May
In my last post I introduced Catalyst::Controller::Accessors, which is mostly aimed at users who do a lot of chaining. This module is similarly targeted for chaining users. Anyone who has used chaining for more than a few weeks will know that exceptions in chains are stupid; an exception will not stop the chain, but merely end the current part of the chain, add to $c->errors, and run the next part of the chain. I would understand this if it were something that you could choose to turn on in a per-chain basis or something, but as a default it’s horrible.
This module solves that problem. It just detaches the chain and sets $c->errors when an exception is thrown. To use it you just need to do the following in your controllers (base controller anyone?):
1 2 3 4 5 6 7 8 9 10 | package MyApp::Controller::Foo; use Moose; BEGIN { extends 'Catalyst::Controller::ActionRole' } __PACKAGE__->config( action_roles => ['DetachOnDie'], ); ...; |
If for some reason you can’t use the excellent Catalyst::Controller::ActionRole you can use the ActionClass version as follows:
1 2 3 4 5 6 7 8 9 10 11 12 | package MyApp::Controller::Foo; use Moose; BEGIN { extends 'Catalyst::Controller' } __PACKAGE__->config( action => { '*' => { ActionClass => 'DetachOnDie' }, }, ); ...; |
3 Responses for "Introducing Catalyst::ActionRole::DetachOnDie"
Err, can you not do this?
Good call Aristotle, updating post now
Thats great thanks for sharing
Leave a reply