Forums / Developer / Catching the Exceptions
Tihomir Dmitrovic
Thursday 18 August 2011 1:19:30 am
Hi,
I want to be able to catch exceptions thrown from my extension. It can be thrown from module or from template operator methods.
There are 2 main reasons I want to do that.
1. I want to log exceptions with their stacktrace (chained exceptions too)
2. If it is some non critical exceptions (e.g NotEnoughCreditsException), I would like to redirect user to particular page (e.g /buy-credits)
I could not find appropriate documentation section which describes the matter. I'm new to ez (but I have 10 years expiriance in php and java web development).
Thanks
André R.
Friday 19 August 2011 3:06:25 am
Only way would be to have a try block inside your module php code and then dispatch the action you would like to execute.There is no way to catch eZ Publish exceptions at root, so the template involved would have to be executed from your own module. Note: exceptions/redirections in templates is not recommend when inside view cache for instance.
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription @: http://twitter.com/andrerom