[Catalyst] Custom error handling

Tomas Doran bobtfish at bobtfish.net
Mon Jul 6 08:22:20 GMT 2009

On 6 Jul 2009, at 02:56, kakimoto at tpg.com.au wrote:
> Using die(' A problem occurred when saving your address. Please try
> again later' );,
> I would get an error message such as "Exception caught in
> myApp::Controller::Subscription->_save_address" which doesn't look so
> good to the users.
> that's why I used $c->error.
> Please tell me if it's bad practice?

No, what you're doing is fine and supported, but I generally arrange  
to throw exception objects (instead of strings).

These don't get in any way mangled by Catalyst, allowing you to  
fiddle with them in end to do things such as internationalizing them,  
or serializing them in API interfaces, and also means that I have  
less flow control to deal with in exceptional cases..

But throwing strings around is however a perfectly valid technique.


More information about the Catalyst mailing list