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


PHP RuntimeException::getLine方法代码示例

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


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

示例1: logError

 /**
  * @param \Zend\Mvc\MvcEvent $oEvent
  * @return \BoilerAppLogger\Logger\MvcLogger
  */
 public function logError(\Zend\Mvc\MvcEvent $oEvent)
 {
     //Create log error
     $oLogError = new \BoilerAppLogger\Entity\LogErrorEntity();
     if (!($oException = $oEvent->getParam('exception')) instanceof \Exception) {
         if (!($oResponse = $oEvent->getResponse()) instanceof \Zend\Http\Response) {
             throw new \LogicException(sprintf('Response expects an instance of \\Zend\\Http\\Response, "%s" given', is_object($oResponse) ? get_class($oResponse) : gettype($oResponse)));
         }
         $oException = new \RuntimeException($oEvent->getError(), $oResponse->getStatusCode());
     } else {
         $oLogError->setLogErrorFile($oException->getFile())->setLogErrorLine($oException->getLine());
     }
     $this->getLogErrorRepository()->create($oLogError->setLogErrorMessage($oException->getMessage())->setLogErrorCode($oException->getCode())->setLogErrorTrace($oException->getTraceAsString())->setLogErrorLog($this->getCurrentLog()));
     return $this;
 }
开发者ID:zf2-boiler-app,项目名称:app-logger,代码行数:19,代码来源:MvcLogger.php

示例2: testCreateWithExceptionWithPrevious

 /**
  * Log events also take an exception as message argument (here with previous exception)
  */
 public function testCreateWithExceptionWithPrevious()
 {
     $logEvent = LogEvent::create(ILogger::LEVEL_ERROR, $this->invargEx, array(), 'PHPUnit');
     $logEventData = $logEvent->getArrayCopy();
     $this->assertNotEmpty($logEventData);
     $this->assertInternalType('array', $logEventData);
     $this->assertArrayHasKey('msg', $logEventData);
     $this->assertArrayHasKey('exception', $logEventData);
     $this->assertEquals($this->invargEx->getMessage(), $logEventData['msg']);
     $this->assertNotEmpty($logEventData['exception']);
     $this->assertInternalType('array', $logEventData['exception']);
     $exceptionArray = $logEventData['exception'];
     $this->assertArrayHasKey('file', $exceptionArray);
     $this->assertArrayHasKey('message', $exceptionArray);
     $this->assertArrayHasKey('code', $exceptionArray);
     $this->assertArrayHasKey('line', $exceptionArray);
     $this->assertArrayHasKey('trace', $exceptionArray);
     $this->assertArrayHasKey('previous', $exceptionArray);
     $this->assertEquals(__FILE__, $exceptionArray['file']);
     $this->assertEquals($this->invargEx->getMessage(), $exceptionArray['message']);
     $this->assertEquals($this->invargEx->getCode(), $exceptionArray['code']);
     $this->assertEquals($this->invargEx->getLine(), $exceptionArray['line']);
     $this->assertNotEmpty($exceptionArray['trace']);
     $previousArray = $exceptionArray['previous'];
     $this->assertArrayHasKey('file', $previousArray);
     $this->assertArrayHasKey('message', $previousArray);
     $this->assertArrayHasKey('code', $previousArray);
     $this->assertArrayHasKey('line', $previousArray);
     $this->assertArrayHasKey('trace', $previousArray);
     $this->assertArrayNotHasKey('previous', $previousArray);
     $this->assertEquals(__FILE__, $previousArray['file']);
     $this->assertEquals($this->runtimeEx->getMessage(), $previousArray['message']);
     $this->assertEquals($this->runtimeEx->getCode(), $previousArray['code']);
     $this->assertEquals($this->runtimeEx->getLine(), $previousArray['line']);
     $this->assertNotEmpty($previousArray['trace']);
 }
开发者ID:zalora,项目名称:punyan,代码行数:39,代码来源:LogEventTest.php

示例3: 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


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