本文整理汇总了PHP中RuntimeException::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP RuntimeException::getFile方法的具体用法?PHP RuntimeException::getFile怎么用?PHP RuntimeException::getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuntimeException
的用法示例。
在下文中一共展示了RuntimeException::getFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}