您好,登录后才能下订单哦!
phpWind的前端控制器AbstractWindFrontController.php中是这样使用的,
/**
* 创建并执行当前应用,单应用访问入口
*/
public function run() {
$this->_app = $this->createApplication($this->_config['web-apps'][$this->_appName],
WindFactory::_getInstance());
set_error_handler(array($this, '_errorHandle'), error_reporting());//调用了当前抽象类中的_errorHandle()方法
set_exception_handler(array($this, '_exceptionHandle'));
if ($this->_config['isclosed']) {
throw new Exception('Sorry, Site has been closed!');
}
if ($this->_chain !== null) $this->_chain->getHandler()->handle('onCreate');
/* @var $router WindRouter */
$router = $this->_app->getFactory()->getInstance('router');
$router->route($this->_app->getRequest());
if ($this->_chain !== null) $this->_chain->getHandler()->handle('onStart');
$this->_app->run($router);
if ($this->_chain !== null) $this->_chain->getHandler()->handle('onResponse');
$this->_app->getResponse()->sendResponse();
$this->_app->getFactory()->executeDestroyMethod();
restore_error_handler();
restore_exception_handler();
}
/**
* 错误处理句柄
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
*/
public function _errorHandle($errno, $errstr, $errfile, $errline) {
if (0 === error_reporting()) return;
restore_error_handler();
/* @var $error WindError */
$error = $this->_app->getFactory()->getInstance('error',
array(
$this->_config['web-apps'][$this->_appName]['error-dir'],
$this->_config['isclosed']));
$error->errorHandle($errno, $errstr, $errfile, $errline);
}
最后调用了WindError基类中的errorHandle()方法,用showErrorMessage()将错误抛出,如下:
/**
* 错误处理句柄
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
*/
public function errorHandle($errno, $errstr, $errfile, $errline) {
$trace = array();
if (Wind::$isDebug) {
$trace = debug_backtrace();
unset($trace[0]["function"], $trace[0]["args"]);
}
$this->showErrorMessage($this->_friendlyErrorType($errno) . ': ' . $errstr, $errfile,
$errline, $trace, $errno);
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。