本文整理汇总了PHP中RuntimeException类的典型用法代码示例。如果您正苦于以下问题:PHP RuntimeException类的具体用法?PHP RuntimeException怎么用?PHP RuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例3: __construct
public function __construct($invalidHelper, array $supportedHelpers, \Exception $previous = null)
{
$message = sprintf('Unsupported helper "%s". It must be one of %s.', $invalidHelper, implode(', ', $supportedHelpers));
parent::__construct($message, 0, $previous);
$this->invalidHelper = $invalidHelper;
$this->supportedHelpers = $supportedHelpers;
}
示例4: __construct
/**
* Public constructor.
*/
public function __construct()
{
$message = 'You must authenticate to access this resource.';
$code = 401;
$this->statusCode = $code;
parent::__construct($message, $code);
}
示例5: __construct
public function __construct($method, array $allowedMethods, \Exception $previous = null)
{
$message = sprintf('Method "%s" is not allowed and must be one of "%s".', $method, implode(', ', $allowedMethods));
parent::__construct($message, 0, $previous);
$this->method = $method;
$this->allowedMethods = $allowedMethods;
}
示例6: __construct
public function __construct($message = "", $code = 403, Exception $previous = null)
{
if (empty($message)) {
$message = \JText::_('LIB_FOF_VIEW_POSSIBLYSUHOSIN');
}
parent::__construct($message, $code, $previous);
}
示例7: __construct
/**
*
* @param string $message
* @param integer $statusCode
* @param \Exception $previous
* @param array $errors
* @param array $headers
*/
public function __construct($message, $statusCode = 0, \Exception $previous = null, array $errors = [], array $headers = [])
{
$this->statusCode = $statusCode;
$this->headers = $headers;
$this->errors = $errors;
parent::__construct($message, $statusCode, $previous);
}
示例8: __construct
/**
* Create an exception based on LibXMLError objects
*
* @param array $errors Array of LibXMLError objects
* @see http://www.php.net/manual/en/class.libxmlerror.php
*/
public function __construct(array $errors)
{
$numErrors = count($errors);
if (1 == $numErrors) {
$message = "An error occurred ";
} elseif ($numErrors > 1) {
$message = "Some errors occurred ";
}
$message .= "while parsing XML configuration file:\n";
foreach ($errors as $error) {
$message .= " - ";
switch ($error->level) {
case LIBXML_ERR_WARNING:
$message .= "Warning {$error->code}: ";
break;
case LIBXML_ERR_ERROR:
$message .= "Error {$error->code}: ";
break;
case LIBXML_ERR_FATAL:
$message .= "Fatal Error {$error->code}: ";
break;
}
$message .= $error->message;
}
parent::__construct($message);
}
示例9: WrongTypeException
public function WrongTypeException($msg = null)
{
if (is_null($msg)) {
$msg = "Tipo inválido";
}
parent::__construct($msg);
}
示例10: __construct
/**
* Creates an instance.
*
* @param string $optionKey
* @param int $target
* @param \Exception $previous
*/
public function __construct($optionKey, $target, \Exception $previous = null)
{
$this->optionKey = $optionKey;
$this->target = $target;
$message = sprintf('Missing value for option "%s" in "%s"', $optionKey, $this->getTargetFQCN());
parent::__construct($message, 0, $previous);
}
示例11: __construct
/**
* @param string $message
* @param string $actorId
* @param \DateTimeInterface $sinceDate
* @param \DateTimeInterface $actualDate
*/
public function __construct($message, $actorId, \DateTimeInterface $sinceDate, \DateTimeInterface $actualDate)
{
parent::__construct($message);
$this->actorId = $actorId;
$this->sinceDate = $sinceDate;
$this->actualDate = $actualDate;
}
示例12: __construct
public function __construct($errorCode, $message, $requestId, $hostId)
{
parent::__construct($message);
$this->requestId = $requestId;
$this->hostId = $hostId;
$this->errorCode = $errorCode;
}
示例13: __construct
public function __construct($message = NULL, $code = 0, \Exception $previous = NULL)
{
if (!isset($message)) {
$message = "rowCount() is supported for DELETE, INSERT, or UPDATE statements performed with structured query builders only, since they would not be portable across database engines otherwise. If the query builders are not sufficient, set the 'return' option to Database::RETURN_AFFECTED to get the number of affected rows.";
}
parent::__construct($message, $code, $previous);
}
示例14: App42Exception3
public function App42Exception3($detailMessage, $httpErrorCode, $appErrorCode)
{
$this->detailMessage = $detailMessage;
$this->httpErrorCode = $httpErrorCode;
$this->appErrorCode = $appErrorCode;
return parent::__construct($detailMessage, $httpErrorCode);
}
示例15: __construct
public function __construct($name, $value = null, $message = null, $code = 0, \Exception $prevException = null)
{
$this->argumentName = $name;
$this->argumentValue = $value;
$message = $message ?: sprintf('The argument for "%s" is invalid.', $name);
parent::__construct($message, $code, $prevException);
}