• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP set_exception_handler函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中set_exception_handler函数的典型用法代码示例。如果您正苦于以下问题:PHP set_exception_handler函数的具体用法?PHP set_exception_handler怎么用?PHP set_exception_handler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_exception_handler函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct(array $config = array())
 {
     $this->_config =& $config;
     // Try to locate app folder.
     if (!isset($config['app_dir'])) {
         $cwd = getcwd();
         while (!is_dir("{$cwd}/app")) {
             if ($cwd == dirname($cwd)) {
                 throw new \LogicException('/app folder not found.');
             }
             $cwd = dirname($cwd);
         }
         $config['app_dir'] = "{$cwd}/app";
     }
     $is_web_request = isset($_SERVER['SERVER_NAME']);
     $config += array('debug' => !$is_web_request || $_SERVER['SERVER_NAME'] == 'localhost', 'register_exception_handler' => $is_web_request, 'register_error_handler' => $is_web_request, 'core_dir' => __DIR__ . '/../..', 'data_dir' => "{$config['app_dir']}/../data");
     $this->exception_handler = new ExceptionHandler($this->debug);
     if ($this->register_exception_handler) {
         set_exception_handler(array($this->exception_handler, 'handle'));
     }
     if ($this->register_error_handler) {
         $this->errorHandler = \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
     }
     foreach (array($config['data_dir'], "{$config['data_dir']}/cache", "{$config['data_dir']}/logs") as $dir) {
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
 }
开发者ID:z7,项目名称:hydra,代码行数:29,代码来源:Core.php


示例2: run

 public function run()
 {
     $this->start = microtime(true);
     ob_start();
     error_reporting(E_STRICT & E_ALL);
     error_reporting(E_STRICT | E_ALL);
     set_error_handler(array(&$this, "errorHandler"));
     KalturaLog::debug("Params [" . print_r($this->params, true) . "]");
     try {
         $this->setSerializerByFormat();
     } catch (Exception $e) {
         return new kRendererDieError($e->getCode(), $e->getMessage());
     }
     if ($this->service == "multirequest") {
         set_exception_handler(null);
         $result = $this->handleMultiRequest();
     } else {
         $success = true;
         $errorCode = null;
         $this->onRequestStart($this->service, $this->action, $this->params);
         try {
             $result = $this->dispatcher->dispatch($this->service, $this->action, $this->params);
         } catch (Exception $ex) {
             $success = false;
             $errorCode = $ex->getCode();
             $result = $this->getExceptionObject($ex, $this->service, $this->action);
         }
         $this->onRequestEnd($success, $errorCode);
     }
     ob_end_clean();
     $this->end = microtime(true);
     return $this->serializeResponse($result);
 }
开发者ID:panigh,项目名称:server,代码行数:33,代码来源:KalturaFrontController.php


示例3: testConsoleEvent

 public function testConsoleEvent()
 {
     $dispatcher = new EventDispatcher();
     $listener = new DebugHandlersListener(null);
     $app = $this->getMock('Symfony\\Component\\Console\\Application');
     $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet()));
     $command = new Command(__FUNCTION__);
     $command->setApplication($app);
     $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput());
     $dispatcher->addSubscriber($listener);
     $xListeners = array(KernelEvents::REQUEST => array(array($listener, 'configure')), ConsoleEvents::COMMAND => array(array($listener, 'configure')));
     $this->assertSame($xListeners, $dispatcher->getListeners());
     $exception = null;
     $eHandler = new ErrorHandler();
     set_error_handler(array($eHandler, 'handleError'));
     set_exception_handler(array($eHandler, 'handleException'));
     try {
         $dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     restore_error_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $xHandler = $eHandler->setExceptionHandler('var_dump');
     $this->assertInstanceOf('Closure', $xHandler);
     $app->expects($this->once())->method('renderException');
     $xHandler(new \Exception());
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:30,代码来源:DebugHandlersListenerTest.php


示例4: testStacking

 /**
  * @expectedException \Symfony\Component\Debug\Exception\DummyException
  */
 public function testStacking()
 {
     // the ContextErrorException must not be loaded to test the workaround
     // for https://bugs.php.net/65322.
     if (class_exists('Symfony\\Component\\Debug\\Exception\\ContextErrorException', false)) {
         $this->markTestSkipped('The ContextErrorException class is already loaded.');
     }
     $exceptionHandler = $this->getMock('Symfony\\Component\\Debug\\ExceptionHandler', array('handle'));
     set_exception_handler(array($exceptionHandler, 'handle'));
     $that = $this;
     $exceptionCheck = function ($exception) use($that) {
         $that->assertInstanceOf('Symfony\\Component\\Debug\\Exception\\ContextErrorException', $exception);
         $that->assertEquals(E_STRICT, $exception->getSeverity());
         $that->assertStringStartsWith(__FILE__, $exception->getFile());
         $that->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage());
     };
     $exceptionHandler->expects($this->once())->method('handle')->will($this->returnCallback($exceptionCheck));
     ErrorHandler::register();
     try {
         // Trigger autoloading + E_STRICT at compile time
         // which in turn triggers $errorHandler->handle()
         // that again triggers autoloading for ContextErrorException.
         // Error stacking works around the bug above and everything is fine.
         eval('
             namespace ' . __NAMESPACE__ . ';
             class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
         ');
     } catch (\Exception $e) {
         restore_error_handler();
         restore_exception_handler();
         throw $e;
     }
     restore_error_handler();
     restore_exception_handler();
 }
开发者ID:romainneutron,项目名称:symfony,代码行数:38,代码来源:DebugClassLoaderTest.php


示例5: run

 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function run()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', "appError"));
     set_exception_handler(array('App', "appException"));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     // 取得模块和操作名称
     define('MODULE_NAME', App::getModule());
     // Module名称
     define('ACTION_NAME', App::getAction());
     // Action操作
     // 记录应用初始化时间
     if (C('SHOW_RUN_TIME')) {
         $GLOBALS['_initTime'] = microtime(TRUE);
     }
     // 执行操作
     R(MODULE_NAME, ACTION_NAME);
     // 保存日志记录
     if (C('LOG_RECORD')) {
         Log::save();
     }
     return;
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:44,代码来源:App.class.php


示例6: onBootstrap

 /**
  * Module bootstrap.
  */
 public function onBootstrap($e)
 {
     $sm = $e->getApplication()->getServiceManager();
     $options = $sm->get('loslog_options');
     if ($options->getUseErrorLogger()) {
         $logger = $sm->get('LosLog\\Log\\ErrorLogger');
         $eventManager = $e->getApplication()->getEventManager();
         $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR, [$logger, 'dispatchError'], -100);
     }
     if ($options->getUseSqlLogger()) {
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $sqlLogger = $sm->get('LosLog\\Log\\SqlLogger');
         $sqlLogger->addLoggerTo($em);
     }
     if ($options->getUseRollbarLogger()) {
         $rollbar = $sm->get('RollbarNotifier');
         if ($options->getExceptionhandler()) {
             set_exception_handler(array($rollbar, 'report_exception'));
             $eventManager = $e->getApplication()->getEventManager();
             $eventManager->attach('dispatch.error', function (Event $event) use($rollbar) {
                 $exception = $event->getResult()->exception;
                 if ($exception) {
                     $rollbar->report_exception($exception);
                 }
             });
         }
         if ($options->getErrorhandler()) {
             set_error_handler(array($rollbar, 'report_php_error'));
         }
         if ($options->getShutdownfunction()) {
             register_shutdown_function($this->shutdownHandler($rollbar));
         }
     }
 }
开发者ID:lafaiDev,项目名称:suive_com,代码行数:37,代码来源:Module.php


示例7: __construct

 /**
  * @param Config $config
  * @param Request $request
  * @param Response $response
  */
 public function __construct(Config $config, Request $request, Response $response)
 {
     $this->config = $config;
     $this->request = $request;
     $this->response = $response;
     set_exception_handler([$this, 'handleException']);
 }
开发者ID:dw250100785,项目名称:b8framework,代码行数:12,代码来源:Handler.php


示例8: __construct

 function __construct($name = '', $desc = '')
 {
     $this->_name = $name;
     $this->_desc = $desc;
     array_push($this->_options, new Option('-h, --help', 'Output usage information'));
     set_exception_handler([$this, 'exception']);
 }
开发者ID:lijinma,项目名称:commander,代码行数:7,代码来源:Commander.php


示例9: enable

 /**
  * This method is used to enable debugging within your Ulfberht application.
  */
 public static function enable()
 {
     error_reporting(E_ALL);
     ini_set('display_errors', '1');
     set_exception_handler(['ulfberht\\debug', 'ulfberhtExceptionHandler']);
     self::$isEnabled = true;
 }
开发者ID:ua1-labs,项目名称:ulfberht,代码行数:10,代码来源:debug.php


示例10: __construct

 public function __construct($plan = null, array $options = array())
 {
     $this->options = array('base_dir' => null, 'output' => 'tap', 'force_colors' => false, 'verbose' => false, 'serialize' => false, 'coverage' => false);
     foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) {
         $this->options[str_replace('-', '_', $argument)] = $value;
     }
     $this->options = array_merge($this->options, $options);
     $this->options['base_dir'] = realpath($this->options['base_dir']);
     list($file, $line) = LimeTrace::findCaller('LimeTest');
     if ($this->options['coverage']) {
         $this->output = new LimeOutputCoverage();
     } elseif (is_string($this->options['output'])) {
         $factory = new LimeOutputFactory($this->options);
         $this->output = $factory->create($this->options['output']);
     } else {
         $this->output = $this->options['output'];
     }
     $this->output->focus($file);
     if (!is_null($plan)) {
         $this->output->plan($plan);
     }
     set_error_handler(array($this, 'handleError'));
     // make sure that exceptions that are not caught by the test runner are
     // caught and formatted in an appropriate way
     set_exception_handler(array($this, 'handleException'));
 }
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:26,代码来源:LimeTest.php


示例11: init

 /**
  * 环境初始化
  * @param array $config
  * @return void
  */
 public static function init(array $config = null)
 {
     if (is_array($config)) {
         self::$config = array_merge(self::$config, $config);
     }
     /**
      * 设置自动载入函数
      */
     if (self::$config['autoload']) {
         if (function_exists('__autoload')) {
             spl_autoload_register('__autoload');
         }
         spl_autoload_register(array('Base_Common', 'autoload'));
     }
     /**
      * GPC
      */
     if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
         $_GET = self::stripslashesRecursive($_GET);
         $_POST = self::stripslashesRecursive($_POST);
         $_COOKIE = self::stripslashesRecursive($_COOKIE);
         reset($_GET);
         reset($_POST);
         reset($_COOKIE);
     }
     /**
      * 设置异常抛出
      */
     set_exception_handler(array('Base_Common', 'exceptionHandle'));
     /**
      * 设置时区
      */
     date_default_timezone_set(self::$config['timezone']);
 }
开发者ID:032404cxd,项目名称:xrace_main,代码行数:39,代码来源:Common.php


示例12: testNotice

 public function testNotice()
 {
     $exceptionHandler = $this->getMock('Symfony\\Component\\Debug\\ExceptionHandler', array('handle'));
     set_exception_handler(array($exceptionHandler, 'handle'));
     $that = $this;
     $exceptionCheck = function ($exception) use($that) {
         $that->assertInstanceOf('Symfony\\Component\\Debug\\Exception\\ContextErrorException', $exception);
         $that->assertEquals(E_NOTICE, $exception->getSeverity());
         $that->assertEquals(__LINE__ + 40, $exception->getLine());
         $that->assertEquals(__FILE__, $exception->getFile());
         $that->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
         $that->assertArrayHasKey('foobar', $exception->getContext());
         $trace = $exception->getTrace();
         $that->assertEquals(__FILE__, $trace[0]['file']);
         $that->assertEquals('Symfony\\Component\\Debug\\ErrorHandler', $trace[0]['class']);
         $that->assertEquals('handle', $trace[0]['function']);
         $that->assertEquals('->', $trace[0]['type']);
         $that->assertEquals(__FILE__, $trace[1]['file']);
         $that->assertEquals(__CLASS__, $trace[1]['class']);
         $that->assertEquals('triggerNotice', $trace[1]['function']);
         $that->assertEquals('::', $trace[1]['type']);
         $that->assertEquals(__CLASS__, $trace[2]['class']);
         $that->assertEquals('testNotice', $trace[2]['function']);
         $that->assertEquals('->', $trace[2]['type']);
     };
     $exceptionHandler->expects($this->once())->method('handle')->will($this->returnCallback($exceptionCheck));
     ErrorHandler::register();
     try {
         self::triggerNotice($this);
     } catch (DummyException $e) {
         // if an exception is thrown, the test passed
     }
     restore_error_handler();
 }
开发者ID:GroupEsi,项目名称:PSE,代码行数:34,代码来源:ErrorHandlerTest.php


示例13: init

 public static function init()
 {
     ### { PHP Config } ###
     ini_set('magic_quotes_gpc', 0);
     ini_set('magic_quotes_runtime', 0);
     ini_set('magic_quotes_sybase', 0);
     ini_set('session.use_only_cookies', 1);
     ini_set('unserialize_callback_func', 'spl_autoload_call');
     ### { Class Autoloading } ###
     spl_autoload_register('Clap::classLoader');
     self::$loadedClass['Clap'] = Clap::LIBRARIES_LOCATION . 'Clap/Clap.php';
     ### { Error & Exception } ###
     error_reporting(E_ALL);
     ini_set('display_errors', true);
     set_error_handler('Clap_Error::errorHandler');
     set_exception_handler('Clap_Error::exceptionHandler');
     ### { Browser Output } ###
     if (!ob_get_level()) {
         ob_start();
     }
     // ignore_user_abort(true);
     ### { Start Services } ###
     $Conf = Clap::getService('Config');
     $Sess = Clap::getService('Session');
     $Cach = Clap::getService('Cache');
     $Site = Clap::getService('Site');
     ### { Site Operations } ###
     $Site->redirForm();
     $Site->exeFlash();
     $Site->insert();
     ### { Send HTML & Save } ###
     $Site->close();
 }
开发者ID:TristanMouchet,项目名称:Clap,代码行数:33,代码来源:Clap.php


示例14: __construct

 /**
  * Constructor.
  *
  * @param   object  &$subject  The object to observe
  * @param   array   $config    An optional associative array of configuration settings.
  *
  * @since   1.6
  */
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Set the error handler for E_ERROR to be the class handleError method.
     JError::setErrorHandling(E_ERROR, 'callback', array('PlgSystemRedirect', 'handleError'));
     set_exception_handler(array('PlgSystemRedirect', 'handleError'));
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:15,代码来源:redirect.php


示例15: init

 static function init()
 {
     set_exception_handler("MVCCore::exception");
     set_error_handler("MVCCore::error");
     register_shutdown_function("MVCCore::shutdown");
     spl_autoload_register("MVCCore::autoload");
 }
开发者ID:jifangshiyanshi,项目名称:kuangjialianxi,代码行数:7,代码来源:MVCCore.class.php


示例16: __construct

 public function __construct(TemplateEngineInterface $templateEngine, $debug = false)
 {
     $this->templateEngine = $templateEngine;
     $this->debug = $debug;
     $exceptionHandler = new ExceptionHandler($templateEngine, $this->debug);
     set_exception_handler(array($exceptionHandler, 'handle'));
 }
开发者ID:jbrat,项目名称:uFrameworkPHP,代码行数:7,代码来源:App.php


示例17: run

 /**
  * Start the App.
  *
  * @return void
  */
 public function run()
 {
     //Define a custom error handler so we can log PHP errors
     set_error_handler(array('\\Kotori\\Core\\Handle', 'error'));
     set_exception_handler(array('\\Kotori\\Core\\Handle', 'exception'));
     register_shutdown_function(array('\\Kotori\\Core\\Handle', 'end'));
     Config::getSoul()->initialize($this->_config);
     ini_set('date.timezone', Config::getSoul()->TIME_ZONE);
     if (Config::getSoul()->USE_SESSION) {
         !session_id() && session_start();
     }
     //Build
     new Build(Config::getSoul()->APP_FULL_PATH);
     //Load application's common functions
     Helper::import(Config::getSoul()->APP_FULL_PATH . '/common.php');
     if (function_exists('spl_autoload_register')) {
         spl_autoload_register(array('\\Kotori\\Core\\Helper', 'autoload'));
     } else {
         function __autoload($className)
         {
             Helper::autoload($className);
         }
     }
     //Load route class
     Route::getSoul()->dispatch();
     //Global security filter
     array_walk_recursive($_GET, array('\\Kotori\\Http\\Request', 'filter'));
     array_walk_recursive($_POST, array('\\Kotori\\Http\\Request', 'filter'));
     array_walk_recursive($_REQUEST, array('\\Kotori\\Http\\Request', 'filter'));
 }
开发者ID:kokororin,项目名称:Kotori.php,代码行数:35,代码来源:App.php


示例18: run

 /**
  * @param string   $model
  * @param string   $action
  * @param array    $params
  *
  * @throws RokCommon_Ajax_Exception
  * @return string
  */
 public static function run($model, $action, $params, $encoding = self::JSON_ENCODING)
 {
     // Set up an independent AJAX error handler
     set_error_handler(array('RokCommon_Ajax', 'error_handler'));
     set_exception_handler(array('RokCommon_Ajax', 'exception_handler'));
     while (@ob_end_clean()) {
     }
     // clean any pending output buffers
     ob_start();
     // start a fresh one
     $result = null;
     try {
         // get a model class instance
         $modelInstance = self::getModel($model);
         if ($encoding == self::JSON_ENCODING) {
             $decoded_params = json_decode($params);
             if (null == $decoded_params && strlen($params) > 0) {
                 throw new RokCommon_Ajax_Exception('Invalid JSON for params');
             }
             $params = $decoded_params;
         }
         // set the result to the run
         $result = $modelInstance->run($action, $params);
     } catch (Exception $ae) {
         $result = new RokCommon_Ajax_Result();
         $result->setAsError();
         $result->setMessage($ae->getMessage());
     }
     $encoded_result = json_encode($result);
     // restore normal error handling;
     restore_error_handler();
     restore_exception_handler();
     return $encoded_result;
 }
开发者ID:networksoft,项目名称:networksoft.com.co,代码行数:42,代码来源:Ajax.php


示例19: setupErrors

 /**
  * Configures PHP error handling.
  * @return void
  */
 public static function setupErrors()
 {
     error_reporting(E_ALL | E_STRICT);
     ini_set('display_errors', TRUE);
     ini_set('html_errors', FALSE);
     ini_set('log_errors', FALSE);
     set_exception_handler(array(__CLASS__, 'handleException'));
     set_error_handler(function ($severity, $message, $file, $line) {
         if (in_array($severity, array(E_RECOVERABLE_ERROR, E_USER_ERROR), TRUE) || ($severity & error_reporting()) === $severity) {
             Environment::handleException(new \ErrorException($message, 0, $severity, $file, $line));
         }
         return FALSE;
     });
     register_shutdown_function(function () {
         Assert::$onFailure = array(__CLASS__, 'handleException');
         // note that Runner is unable to catch this errors in CLI & PHP 5.4.0 - 5.4.6 due PHP bug #62725
         $error = error_get_last();
         register_shutdown_function(function () use($error) {
             if (in_array($error['type'], array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE), TRUE)) {
                 if (($error['type'] & error_reporting()) !== $error['type']) {
                     // show fatal errors hidden by @shutup
                     echo "\nFatal error: {$error['message']} in {$error['file']} on line {$error['line']}\n";
                 }
             } elseif (Environment::$checkAssertions && !Assert::$counter) {
                 echo "\nError: This test forgets to execute an assertion.\n";
                 exit(Runner\Job::CODE_FAIL);
             }
         });
     });
 }
开发者ID:cujan,项目名称:vcelyweb,代码行数:34,代码来源:Environment.php


示例20: register

 public function register()
 {
     ini_set('display_errors', false);
     set_exception_handler([$this, 'handleException']);
     set_error_handler([$this, 'handleError']);
     register_shutdown_function([$this, 'handleFatalError']);
 }
开发者ID:aoyel,项目名称:pinst,代码行数:7,代码来源:ErrorHandel.php



注:本文中的set_exception_handler函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP set_field函数代码示例发布时间:2022-05-15
下一篇:
PHP set_error_handler函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap