本文整理汇总了PHP中restore_exception_handler函数的典型用法代码示例。如果您正苦于以下问题:PHP restore_exception_handler函数的具体用法?PHP restore_exception_handler怎么用?PHP restore_exception_handler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了restore_exception_handler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unregister
/**
* Attempts to unregister the error handler, restores the previous
*/
function unregister()
{
restore_error_handler();
restore_exception_handler();
$this->_registered = false;
return $this;
}
示例2: errorHandler
/**
* 负责分发错误到日志记录
*/
public static function errorHandler($errno, $errstr, $errfile, $errline, $obj)
{
restore_error_handler();
restore_exception_handler();
// 处理@符号的情况
if (!(error_reporting() !== 0 && $errno)) {
return;
}
switch ($errno) {
case E_NOTICE:
case E_USER_NOTICE:
$errors = "Notice";
break;
case E_WARNING:
case E_USER_WARNING:
$errors = "Warning";
break;
case E_ERROR:
case E_USER_ERROR:
$errors = "Fatal Error";
break;
default:
$errors = "Unknown";
break;
}
Flow::Log()->clear();
Flow::Log()->error(sprintf("%s in %s on line %d", $errstr, $errfile, $errline));
self::dieErrorLogs();
return false;
}
示例3: __construct
/**
* constructor initializes the default database connection
*/
public function __construct()
{
set_exception_handler(array(__CLASS__, 'fallback_handler'));
restore_exception_handler();
Config::set('db_dsn', 'mysql:host=' . Config::get('db_host') . ';dbname=' . Config::get('db_name'));
$this->initDB();
}
示例4: __construct
/**
* Constructor
*
* @param HTTP\Request $request
* @param HTTP\Response $response
* @param string $format one of png, jpeg, gif
*/
public function __construct(HTTP\Request $request, HTTP\Response $response, $format = 'png')
{
parent::__construct($request, $response);
// to enabled jpgraphs graphical exception handler
restore_exception_handler();
if ($this->request->getParameter('width')) {
$this->width = $this->request->getParameter('width');
}
if ($this->request->getParameter('height')) {
$this->height = $this->request->getParameter('height');
}
$this->colors = Util\Configuration::read('colors');
$this->graph = new \Graph($this->width, $this->height);
$this->graph->img->SetImgFormat($format);
// Specify what scale we want to use,
$this->graph->SetScale('datlin');
$this->graph->legend->SetPos(0.03, 0.06);
$this->graph->legend->SetShadow(FALSE);
$this->graph->legend->SetFrameWeight(1);
$this->graph->SetMarginColor('white');
$this->graph->SetYDeltaDist(65);
$this->graph->yaxis->SetTitlemargin(36);
$this->graph->SetTickDensity(TICKD_DENSE, TICKD_SPARSE);
$this->graph->xaxis->SetFont(FF_ARIAL);
$this->graph->xaxis->SetLabelAngle(45);
$this->graph->xaxis->SetLabelFormatCallback(function ($label) {
return date('j.n.y G:i', $label);
});
$this->graph->img->SetAntiAliasing(function_exists('imageantialias'));
}
示例5: __construct
public function __construct()
{
set_exception_handler(array(__CLASS__, 'fallback_handler'));
//database init
$this->dbh = new PDO(Config::get('dsn'), Config::get('db_user'), Config::get('db_pass'));
restore_exception_handler();
}
示例6: getCurrentExceptionHandler
/**
* Returns the callable currently registered to handle uncaught exceptions
*
* @return callable
*/
protected function getCurrentExceptionHandler()
{
$handler = set_exception_handler(function () {
});
restore_exception_handler();
return $handler;
}
示例7: handleException
public function handleException($exception)
{
// disable error capturing to avoid recursive errors
restore_error_handler();
restore_exception_handler();
// $event=new Exception($this,$exception);
if ($exception instanceof NotFoundHttpException && !isset($_GET['r'])) {
echo Yii::$app->runAction("wordpress-loader");
// try
// {
//
//// $results = Yii::$app->runAction("wordpress-loader");
//// Yii::$app->end();
// }
// catch(\Exception $exception) {
//
// var_dump($exception);
// die;
//
// }
// if we throw an exception in Wordpress on a 404, we can use
// our main error handler to handle the error
}
// if(!$event->handled)
// {
// Yii::$app->handleException($exception);
// }
}
示例8: testConfigure
public function testConfigure()
{
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$userHandler = function () {
};
$listener = new DebugHandlersListener($userHandler, $logger);
$xHandler = new ExceptionHandler();
$eHandler = new ErrorHandler();
$eHandler->setExceptionHandler(array($xHandler, 'handle'));
$exception = null;
set_error_handler(array($eHandler, 'handleError'));
set_exception_handler(array($eHandler, 'handleException'));
try {
$listener->configure();
} catch (\Exception $exception) {
}
restore_exception_handler();
restore_error_handler();
if (null !== $exception) {
throw $exception;
}
$this->assertSame($userHandler, $xHandler->setHandler('var_dump'));
$loggers = $eHandler->setLoggers(array());
$this->assertArrayHasKey(E_DEPRECATED, $loggers);
$this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]);
}
示例9: run
/**
* @param $modelname
*
* @internal param string $encoding
*
* @return string
*/
public function run($modelname)
{
// Set up an independent AJAX error handler
set_error_handler(array($this, 'error_handler'));
set_exception_handler(array($this, 'exception_handler'));
while (@ob_end_clean()) {
}
// clean any pending output buffers
ob_start();
// start a fresh one
try {
$container = RokUpdater_ServiceProvider::getInstance();
$model_container_name = self::DEFAULT_MODEL_CONTEXT_PREFIX . strtolower($modelname);
/** @var RokUpdater_Ajax_IModel $model */
$model = $container->{$model_container_name};
// set the result to the run
$result = $model->run();
} catch (Exception $ae) {
$result = new stdClass();
$result->status = "error";
$result->message = $ae->getMessage();
$result = json_encode($result);
}
// restore normal error handling;
restore_error_handler();
restore_exception_handler();
return $result;
}
示例10: main
/**
* Start the shell and interactive console.
*
* @return int|void
*/
public function main()
{
if (!class_exists('Psy\\Shell')) {
$this->err('<error>Unable to load Psy\\Shell.</error>');
$this->err('');
$this->err('Make sure you have installed psysh as a dependency,');
$this->err('and that Psy\\Shell is registered in your autoloader.');
$this->err('');
$this->err('If you are using composer run');
$this->err('');
$this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
$this->err('');
return 1;
}
$this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
$this->out('');
Log::drop('debug');
Log::drop('error');
$this->_io->setLoggers(false);
restore_error_handler();
restore_exception_handler();
$psy = new PsyShell();
$psy->run();
return 0;
}
示例11: disableExceptionTrapping
public static function disableExceptionTrapping()
{
self::$exceptionTrappingOn = false;
ini_set("display_errors", true);
restore_error_handler();
restore_exception_handler();
}
示例12: _call
static function _call($c)
{
try {
if (__CLASS__ . '::' !== self::$class) {
array_unshift($c, self::$class . __FUNCTION__);
}
call_user_func_array(array_shift($c), $c);
} catch (\Exception $e) {
$c = set_exception_handler('var_dump');
restore_exception_handler();
if (null !== $c) {
call_user_func($c, $e);
} else {
/**/
if (PHP_VERSION_ID >= 50306) {
throw $e;
/**/
} else {
user_error("Uncaught exception '" . get_class($e) . "'" . ('' !== $e->getMessage() ? " with message '{$e->getMessage()}'" : "") . " in {$e->getFile()}:{$e->getLine()}" . PHP_EOL . "Stack trace:" . PHP_EOL . "{$e->getTraceAsString()}" . PHP_EOL, E_USER_WARNING);
/**/
}
}
exit(255);
}
}
示例13: __construct
public function __construct()
{
$details = Config::get('Database');
set_exception_handler(array(__CLASS__, 'error_handler'));
parent::__construct("mysql:host={$details['host']};dbname={$details['name']}", $details['user'], $details['password']);
restore_exception_handler();
}
示例14: tearDown
public function tearDown()
{
ini_set('display_errors', $this->displayErrors);
error_reporting($this->errorReporting);
restore_error_handler();
restore_exception_handler();
}
示例15: configure_environment
/**
* Configures the environment for testing
*
* Does the following:
*
* * Loads the phpunit framework (for the web ui)
* * Restores exception phpunit error handlers (for cli)
* * registeres an autoloader to load test files
*/
public static function configure_environment($do_whitelist = TRUE, $do_blacklist = TRUE)
{
// During a webui request we need to manually load PHPUnit
if (!class_exists('PHPUnit_Util_Filter', FALSE) and !function_exists('phpunit_autoload')) {
try {
include_once 'PHPUnit/Autoload.php';
} catch (ErrorException $e) {
include_once 'PHPUnit/Framework.php';
}
}
// Allow PHPUnit to handle exceptions and errors
if (Kohana::$is_cli) {
restore_exception_handler();
restore_error_handler();
}
spl_autoload_register(array('Kohana_Tests', 'autoload'));
Kohana_Tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache;
// As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted
self::$phpunit_v35 = function_exists('phpunit_autoload');
$config = Kohana::config('unittest');
if ($do_whitelist and $config->use_whitelist) {
self::whitelist();
}
if ($do_blacklist and count($config['blacklist'])) {
Kohana_Tests::blacklist($config->blacklist);
}
}