Created
February 9, 2010 02:06
-
-
Save monzee/298848 to your computer and use it in GitHub Desktop.
Catching early exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* APPLICATION_PATH/Bootstrap.php */ | |
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap | |
{ | |
protected $_appNamespace = 'Application_'; | |
protected function _initFoo() | |
{ | |
throw new BadMethodCallException('foo!'); | |
} | |
protected function _bootstrap($resource = null) | |
{ | |
try { | |
parent::_bootstrap($resource); | |
} catch (Exception $e) { | |
parent::_bootstrap('frontController'); | |
$front = $this->getResource('frontController'); | |
$front->registerPlugin(new Application_Plugin_BootstrapError($e)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* APPLICATION_PATH/plugins/BootstrapError.php */ | |
class Application_Plugin_BootstrapError extends Zend_Controller_Plugin_Abstract | |
{ | |
protected $_exception; | |
public function __construct(Exception $exception) | |
{ | |
$this->_exception = $exception; | |
} | |
public function routeStartup($request) | |
{ | |
throw $this->_exception; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment