Authored by 周少峰

error

<?php
namespace WebPlugin;
/**
* 辅助类
*/
class TriggerError
{
public static function myErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case \Yaf\ERR\NOTFOUD\CONTROLLER:
case \Yaf\ERR\NOTFOUD\MODULE:
case \Yaf\ERR\NOTFOUD\ACTION:
header("Not Found");
break;
default:
echo 'ehre';
echo "Unknown error type: [$errno] $errstr<br />\n";
break;
}
return true;
}
}
... ...
... ... @@ -149,6 +149,28 @@ class Bootstrap extends Bootstrap_Abstract
//}
}
public function _initError(Dispatcher $dispatcher)
{
$dispatcher->getInstance()->setErrorHandler(array($this,"myErrorHandler"));
// $dispatcher->getInstance()->setErrorHandler(array("\\WebPlugin\\TriggerError","myErrorHandler"));
}
public static function myErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case YAF_ERR_NOTFOUND_CONTROLLER:
case YAF_ERR_NOTFOUND_MODULE:
case YAF_ERR_NOTFOUND_ACTION:
header("Not Found");
break;
default:
echo "Unknown error type: [$errno] $errstr<br />\n";
break;
}
return true;
}
// /**
// * 初始化第三方包
// * @param Dispatcher $dispatcher
... ...