« Return to Thread: Custom error handling

Re: Custom error handling

by Tomas Doran :: Rate this Message:

Reply to Author | View in Thread


On 6 Jul 2009, at 02:56, kakimoto@... 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.

Cheers
t0m


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

 « Return to Thread: Custom error handling