Skip to content

Instantly share code, notes, and snippets.

@monzee
Created February 9, 2010 02:06
Show Gist options
  • Save monzee/298848 to your computer and use it in GitHub Desktop.
Save monzee/298848 to your computer and use it in GitHub Desktop.
Catching early exceptions
<?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));
}
}
}
<?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