lunedì 9 maggio 2011

Why use try - catch inside the controllers?

So you have a nice MVC website.

All is perfect until one of your models throws an error
If you use use Zend Framework you will get this ugly error :



So let's help the user. Inside our controller we have to put the whole body of each myactionAction()  into a try - catch and add the error's message to the Zend Flash Messenger(while you are at it you might even translate it to a user friendly message). Then just redirect to a page you know it will not throw any errors and in the view you use jQuery UI CSS  and print it to get this nice picture :)


that's all

Nessun commento:

Posta un commento