当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorHandler::customHandler方法代码示例

本文整理汇总了PHP中ErrorHandler::customHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::customHandler方法的具体用法?PHP ErrorHandler::customHandler怎么用?PHP ErrorHandler::customHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorHandler的用法示例。


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

示例1: run

 public static function run($page = false, $db = false, $options = [])
 {
     ErrorHandler::$customHandler = function ($errno, $errstr, $errfile, $errline, $errcontext, $errorName) {
         $controller = new ApiController();
         $controller->errorResponse("Unknown Error", "{$errorName} {$errstr}", "{$errfile} on line {$errline}");
     };
     parent::run($page, $db, $options);
 }
开发者ID:fierce,项目名称:fierce,代码行数:8,代码来源:ApiController.php

示例2: runAction

 function runAction()
 {
     ErrorHandler::$customHandler = function ($errno, $errstr, $errfile, $errline, $errcontext, $errorName) {
         $this->fail("{$errorName} {$errstr}\n{$errfile} on line {$errline}");
         print '<hr>';
         print "<p>\n        Aborted with <span id=\"test-status-pass-count\">{$this->passCount}</span> passe" . ($this->passCount == 1 ? '' : 's') . ",\n        <span id=\"test-status-fail-count\">{$this->failCount}</span> fail" . ($this->failCount == 1 ? '' : 's') . ".\n      </p>";
         $this->printFoot();
         exit;
     };
     try {
         $files = $this->testFiles();
         $testFile = $files[$_GET['test']];
         if (!$testFile) {
             die('cannot find test');
         }
         $this->__testFile = $testFile;
         $this->__buffered = preg_match('/-with-buffer.php/', $testFile);
         if ($this->__buffered) {
             ob_start();
         }
         $this->printHead();
         print '<h3>' . htmlentities($this->nameForTestFile($testFile)) . '</h3>';
         $relativePath = substr($testFile, strlen(Env::get('base_path')));
         print "<pre>{$relativePath}</pre>";
         print '<hr>';
         print '<p><a href="test.php">« Back to test list</a></p>';
         print '<hr>';
         print '<ul id="test-list">';
         require $testFile;
         print '</ul>';
         print '<hr>';
         print "<p>\n      Completed with <span id=\"test-status-pass-count\">{$this->passCount}</span> passe" . ($this->passCount == 1 ? '' : 's') . ",\n      <span id=\"test-status-fail-count\">{$this->failCount}</span> fail" . ($this->failCount == 1 ? '' : 's') . ".\n    </p>";
         $this->printFoot();
         if ($this->__buffered) {
             ob_end_flush();
         }
     } catch (\Exception $e) {
         $this->fail('Exception: ' . $e->getMessage() . "\n" . $e->getTraceAsString());
         print '<hr>';
         print "<p>\n        Aborted with <span id=\"test-status-pass-count\">{$this->passCount}</span> passe" . ($this->passCount == 1 ? '' : 's') . ",\n        <span id=\"test-status-fail-count\">{$this->failCount}</span> fail" . ($this->failCount == 1 ? '' : 's') . ".\n      </p>";
         $this->printFoot();
         exit;
     }
 }
开发者ID:fierce,项目名称:fierce,代码行数:44,代码来源:TestsController.php


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