File tree Expand file tree Collapse file tree 3 files changed +76
-24
lines changed Expand file tree Collapse file tree 3 files changed +76
-24
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,31 @@ modman init modman clone
2525[email protected] :wearefarm/magento-sentry-extension.git
2626```
2727
28+ ## Installation: enabling Magento Exception handling
29+
30+ Because Magento catches all exceptions via a global try/catch construct
31+ ` set_exception_handler ` doesn't work (the exception handler is never reached).
32+ With a small addition to ` app/Mage.php ` this can be fixed:
33+
34+ ``` php
35+ public static function run($code = '', $type = 'store', $options = array())
36+ {
37+ ......
38+ } catch (Exception $e) {
39+ if (self::isInstalled() || self::$_isDownloader) {
40+ //add this line
41+ self::dispatchEvent('mage_run_exception',array('exception' => $e));
42+ //-----------------------------------------------------------------
43+ self::printException($e);
44+ exit();
45+ }
46+ }
47+ ```
48+
49+ I hope Magento will include this patch in Magento. Another solution could be
50+ [ PHP's runkit] ( http://www.php.net/manual/en/book.runkit.php ) or editing
51+ ` errors/report.php ` .
52+
2853## Configuration
2954
3055In your Magento back-office, go to System → Configuration → Advanced → Developer
Original file line number Diff line number Diff line change 22
33class AMG_Sentry_Model_Observer {
44
5- public function initSentryLogger ($ observer ){
5+ public $ error_handler ;
6+
7+ public function __construct ()
8+ {
69 if (Mage::getStoreConfigFlag ('dev/amg-sentry/active ' )) {
710 // Instantiate a new client
811 $ client = Mage::getSingleton ('amg-sentry/client ' );
912
1013 // Install error handlers and shutdown function to catch fatal errors
11- $ error_handler = new Raven_ErrorHandler ($ client );
14+ $ this ->error_handler = new Raven_ErrorHandler ($ client );
15+ }
16+
17+ return $ this ;
18+ }
1219
20+ public function initSentryLogger ($ observer ){
21+ if ($ error_handler = $ this ->error_handler ) {
1322 // Check if we should log errors, warnings etc.
1423 if (Mage::getStoreConfigFlag ('dev/amg-sentry/php-errors ' )) {
1524 $ error_handler ->registerErrorHandler ();
@@ -25,5 +34,14 @@ public function initSentryLogger($observer){
2534 $ error_handler ->registerShutdownFunction ();
2635 }
2736 }
37+
38+ return $ this ;
39+ }
40+
41+ public function mageRunException ($ observer )
42+ {
43+ $ exception = $ observer ->getException ();
44+ $ this ->error_handler ->handleException ($ exception );
45+ return $ this ;
2846 }
2947}
Original file line number Diff line number Diff line change 1010 It is also available through the world-wide-web at this URL:
1111 http://opensource.org/licenses/osl-3.0.php
1212
13- @category AMG
14- @package AMG_Sentry
15- @copyright Copyright © 2012 Jean Roussel <[email protected] > 16- @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13+ @category AMG
14+ @package AMG_Sentry
15+ @copyright Copyright © 2012 Jean Roussel <[email protected] > 16+ @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1717
1818-->
1919<config >
20- <modules >
21- <AMG_Sentry >
22- <version >1.0.0</version >
23- </AMG_Sentry >
24- </modules >
25- <global >
20+ <modules >
21+ <AMG_Sentry >
22+ <version >1.0.0</version >
23+ </AMG_Sentry >
24+ </modules >
25+ <global >
2626 <models >
2727 <amg-sentry >
2828 <class >AMG_Sentry_Model</class >
2929 </amg-sentry >
3030 </models >
31- <events >
31+ <events >
3232 <controller_action_predispatch >
3333 <observers >
3434 <amg-sentry_controller_action_predispatch >
3737 <method >initSentryLogger</method >
3838 </amg-sentry_controller_action_predispatch >
3939 </observers >
40- </controller_action_predispatch >
40+ </controller_action_predispatch >
41+ <mage_run_exception >
42+ <observers >
43+ <amg-sentry_mage_run_exceptioin >
44+ <type >singleton</type >
45+ <class >amg-sentry/observer</class >
46+ <method >mageRunException</method >
47+ </amg-sentry_mage_run_exceptioin >
48+ </observers >
49+ </mage_run_exception >
4150 </events >
42- </global >
43- <default >
44- <dev >
45- <amg-sentry >
46- <active >false</active >
47- <
dsn >http://public:
[email protected] :9000/[PROJECT_ID]</
dsn >
48- <logger >magento</logger >
51+ </global >
52+ <default >
53+ <dev >
54+ <amg-sentry >
55+ <active >false</active >
56+ <
dsn >http://public:
[email protected] :9000/[PROJECT_ID]</
dsn >
57+ <logger >magento</logger >
4958 <php-errors >false</php-errors >
5059 <php-exceptions >false</php-exceptions >
5160 <php-fatal-errors >false</php-fatal-errors >
52- </amg-sentry >
53- </dev >
54- </default >
61+ </amg-sentry >
62+ </dev >
63+ </default >
5564</config >
You can’t perform that action at this time.
0 commit comments