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


PHP RuntimeException::getPrevious方法代码示例

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


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

示例1: testDefFormatWithPreviousException

 public function testDefFormatWithPreviousException()
 {
     $formatter = new JsonFormatter();
     $exception = new \RuntimeException('Foo', 0, new \LogicException('Wut?'));
     $formattedPrevException = $this->formatException($exception->getPrevious());
     $formattedException = $this->formatException($exception, $formattedPrevException);
     $message = $this->formatRecordWithExceptionInContext($formatter, $exception);
     $this->assertContextContainsFormattedException($formattedException, $message);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:9,代码来源:JsonFormatterTest.php

示例2: testDefFormatWithPreviousException

 public function testDefFormatWithPreviousException()
 {
     $formatter = new JsonFormatter();
     $exception = new \RuntimeException('Foo', 0, new \LogicException('Wut?'));
     $message = $formatter->format(array('level_name' => 'CRITICAL', 'channel' => 'core', 'context' => array('exception' => $exception), 'datetime' => new \DateTime(), 'extra' => array(), 'message' => 'foobar'));
     if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
         $pathPrevious = substr(json_encode($exception->getPrevious()->getFile(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), 1, -1);
         $pathException = substr(json_encode($exception->getFile(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), 1, -1);
     } else {
         $pathPrevious = substr(json_encode($exception->getPrevious()->getFile()), 1, -1);
         $pathException = substr(json_encode($exception->getFile()), 1, -1);
     }
     $this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"' . $exception->getMessage() . '","code":' . $exception->getCode() . ',"file":"' . $pathException . ':' . $exception->getLine() . '","previous":{"class":"LogicException","message":"' . $exception->getPrevious()->getMessage() . '","code":' . $exception->getPrevious()->getCode() . ',"file":"' . $pathPrevious . ':' . $exception->getPrevious()->getLine() . '"}}},"datetime":' . json_encode(new \DateTime()) . ',"extra":[],"message":"foobar"}' . "\n", $message);
 }
开发者ID:jorjoh,项目名称:Varden,代码行数:14,代码来源:JsonFormatterTest.php

示例3: logException

 public static function logException($exception)
 {
     if (is_string($exception)) {
         $exception = new \RuntimeException($exception);
     }
     if (self::$error === true || !self::$currentRootSpan || !$exception instanceof \Exception) {
         return;
     }
     // We are only interested in the original exception
     while ($previous = $exception->getPrevious()) {
         $exception = $previous;
     }
     self::$error = true;
     self::$currentRootSpan->annotate(array("err_msg" => $exception->getMessage(), "err_source" => $exception->getFile() . ':' . $exception->getLine(), "err_exception" => get_class($exception), "err_trace" => \Tideways\Profiler\BacktraceConverter::convertToString($exception->getTrace())));
 }
开发者ID:tideways,项目名称:profiler,代码行数:15,代码来源:Tideways.php


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