Catching the Exceptions

Author Message

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 13:44:52
Script start
Timing: Jan 29 2025 13:44:52
Module start 'layout'
Timing: Jan 29 2025 13:44:52
Module start 'content'
Timing: Jan 29 2025 13:44:52
Module end 'content'
Timing: Jan 29 2025 13:44:52
Script end

Main resources:

Total runtime0.0118 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.1250151.2109
Module start 'layout' 0.00500.0018 739.335936.6563
Module start 'content' 0.00680.0037 775.992290.1406
Module end 'content' 0.01060.0012 866.132829.9766
Script end 0.0118  896.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002118.1822140.0002
Check MTime0.00108.3645140.0001
Mysql Total
Database connection0.00097.974910.0009
Mysqli_queries0.002016.575530.0007
Looping result0.00000.076710.0000
Template Total0.00108.110.0010
Template load0.00076.138110.0007
Template processing0.00021.929610.0002
Override
Cache load0.00054.047010.0005
General
dbfile0.00021.810580.0000
String conversion0.00000.163540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs