您好,登錄后才能下訂單哦!
phpWind的前端控制器AbstractWindFrontController.php中是這樣使用的,
/**
* 創(chuàng)建并執(zhí)行當前應(yīng)用,單應(yīng)用訪問入口
*/
public function run() {
$this->_app = $this->createApplication($this->_config['web-apps'][$this->_appName],
WindFactory::_getInstance());
set_error_handler(array($this, '_errorHandle'), error_reporting());//調(diào)用了當前抽象類中的_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);
}
最后調(diào)用了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);
}
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。