本文整理汇总了PHP中Symfony\Component\HttpKernel\Exception\HttpException::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpException::__construct方法的具体用法?PHP HttpException::__construct怎么用?PHP HttpException::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Exception\HttpException
的用法示例。
在下文中一共展示了HttpException::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $message
* @param int $code
* @param \Exception $previous
*/
public function __construct($message = null, $code = 0, \Exception $previous = null)
{
/*
* @see https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
*/
parent::__construct(599, $message, $previous, array(), $code);
}
示例2: __construct
public function __construct($message = null)
{
if (!$message) {
$message = $this->generic;
}
parent::__construct(500, $message);
}
示例3: __construct
public function __construct(ApiProblem $apiProblem, \Exception $previous = null, array $headers = array(), $code = 0)
{
$this->apiProblem = $apiProblem;
$statusCode = $apiProblem->getStatusCode();
$message = $apiProblem->getTitle();
parent::__construct($statusCode, $message, $previous, $headers, $code);
}
示例4: __construct
/**
* Constructor.
*
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param int $code The internal exception code
*/
public function __construct($message = null, \Exception $previous = null, $code = 0)
{
if (!$message) {
$message = \Lang::get('api-proxy-laravel::messages.proxy_cookie_invalid');
}
parent::__construct(500, $message, $previous, array(), $code);
}
示例5: __construct
/**
* Create a new rate limit exceeded exception instance.
*
* @param string $message
* @param \Exception $previous
* @param array $headers
* @param int $code
*
* @return void
*/
public function __construct($message = null, Exception $previous = null, $headers = [], $code = 0)
{
if (array_key_exists('X-RateLimit-Reset', $headers)) {
$headers['Retry-After'] = $headers['X-RateLimit-Reset'] - time();
}
parent::__construct(429, $message ?: 'You have exceeded your rate limit.', $previous, $headers, $code);
}
示例6: __construct
public function __construct(Validator $validator)
{
$errors = '';
foreach ($validator->errors()->getMessages() as $key => $messages) {
$errors .= implode(' ', $messages) . ' ';
}
parent::__construct(422, trim($errors));
}
示例7: __construct
/**
* JsonSchemaException constructor.
*
* @param Error[] $errors
*/
public function __construct(array $errors)
{
$messages = [];
foreach ($errors as $error) {
$messages[$error->getProperty()] = $error->getViolation();
}
parent::__construct(400, json_encode($messages));
}
示例8: __construct
public function __construct($servedClass = null, $userModel)
{
if (!$servedClass) {
$message = $this->generic;
} else {
$message = "Transformer cannot serve " . get_class($userModel) . " expected [{$servedClass}]";
}
parent::__construct(500, $message);
}
示例9: __construct
/**
* Create a new resource exception instance.
*
* @param string $message
* @param \Illuminate\Support\MessageBag|array $errors
* @param \Exception $previous
* @param array $headers
* @param int $code
*
* @return void
*/
public function __construct($message = null, $errors = null, Exception $previous = null, $headers = [], $code = 0)
{
if (is_null($errors)) {
$this->errors = new MessageBag();
} else {
$this->errors = is_array($errors) ? new MessageBag($errors) : $errors;
}
parent::__construct(422, $message, $previous, $headers, $code);
}
示例10: __construct
public function __construct($statusCode, array $messages)
{
$this->messages = $messages;
$flattenedMessages = [];
array_walk_recursive($messages, function ($a) use(&$flattenedMessages) {
$flattenedMessages[] = $a;
});
$message = implode(' ', $flattenedMessages);
parent::__construct($statusCode, $message);
}
示例11: __construct
/**
* ResourceException constructor.
*
* @param null $message
* @param null $errors
* @param \Exception|null $previous
* @param array $headers
* @param int $code
*/
public function __construct($message = null, $errors = null, Exception $previous = null, array $headers = [], $code = 0)
{
parent::__construct(422, $message, $previous, $headers, $code);
if ($errors instanceof MessageBagInterface) {
$this->errors = $errors;
} elseif (is_array($errors)) {
$this->errors = new MessageBag($errors);
} elseif ($errors instanceof Collection) {
$this->errors = new MessageBag($errors->all());
} else {
$this->errors = new MessageBag();
}
}
示例12: __construct
/**
* Create a new Service Unavailable exception instance.
*
* @param string $message
* @param int $code
* @param \Exception $previous
*/
public function __construct($message = 'Service Unavailable.', $code = 0, Exception $previous = null)
{
parent::__construct(Response::HTTP_SERVICE_UNAVAILABLE, $message, $previous);
}
示例13: __construct
public function __construct($message, $code)
{
parent::__construct($code, $message, null, [], $code);
}
示例14: __construct
/**
* Constructor.
*
* @param string $message The internal exception message
* @param Exception $previous The previous exception
* @param integer $code The internal exception code
*/
public function __construct($message = null, \Exception $previous = null, $code = 0)
{
parent::__construct(503, $message, $previous, array(), $code);
}
示例15: __construct
/**
* An enhanced constructor that allows for passing the default \Exception parameters, as well as an array of additional
* attributes followed by any number of additional arguments that will be passed to sprintf against the message.
*
* @param string|null $message An error message string (optionally fed to sprintf if optional args are given)
* @param int|null $code The error code (which should be from ORMExceptionInterface). If null, the value
* of ExceptionInterface::CODE_GENERIC will be used.
* @param mixed $previous The previous exception (when re-thrown within another exception), if applicable.
* @param mixed[]|null $attributes An optional array of attributes to pass. Will be provided in the debug output.
* @param mixed ...$sprintfArgs Optional additional parameters that will be passed to sprintf against the
* message string provided.
*/
public function __construct($message = null, $code = null, $previous = null, ...$sprintfArgs)
{
parent::__construct($this->getFinalCode((int) $code), $this->getFinalMessage((string) $message, ...$sprintfArgs), $this->getFinalPrevious($previous), $this->getFinalCode((int) $code));
$this->setAttributes([]);
}