This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Catching the Exceptions
expandshrink

Catching the Exceptions

Catching the Exceptions

Thursday 18 August 2011 10:19:30 am - 2 replies

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

Friday 19 August 2011 12:06:25 pm

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.

Modified on Friday 19 August 2011 12:06:56 pm by André R

Friday 27 April 2012 11:25:53 am

I am struggling with this as well.. I have my own module where i try to catch exceptions from within my custom php classes. I am not able to get the exception to work.

Do you have any example code on how to do this the best way or is simply not exception handling implemented well enough in the current edition of eZ?

Update::

Just figured out that my exception was caught by myself at an earlier stage.. therefor it was not working as expected. Throwing the exception further up the hierarchy works well.

Modified on Friday 27 April 2012 2:34:35 pm by Lars Eirik Roenning

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from