[Catalyst] error handling (Chain where ajax and non-ajax actions chain off)

Ben van Staveren benvanstaveren at gmail.com
Tue Nov 9 10:39:43 GMT 2010

A bit offtopic but why use the trait at all, you can just check the 
x-requested-with header for the 'XMLHttpRequest' value - saves you a 
dependency. As far as the status_not_found routine, I suggest a liberal 
bit of cut 'n paste and using View::JSON (sort of negates the losing of 
one dependency if you give up the trait, unless you're using it already).

David Schmidt wrote:
> Hello list
> Both ajax and non-ajax actions chain off the same action
> (base_with_id). If an error occurs (like the resource doesn't exist) I
> detach to '/error404' in my Root Controller.
> I just introduced the ajax stuff and before that 'error404' simply
> rendered an error template. Now I'd like to check if it is an xmlhttp
> request using http://search.cpan.org/~flora/Catalyst-TraitFor-Request-XMLHttpRequest-0.01/
> and then either render the error template like before OR use the
> status_not_found() helper from
> http://search.cpan.org/~bobtfish/Catalyst-Action-REST-0.87/

Ben van Staveren
phone: +62 81 70777529
email: benvanstaveren at gmail.com

More information about the Catalyst mailing list