本文整理汇总了PHP中Exception::getHttpStatusCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getHttpStatusCode方法的具体用法?PHP Exception::getHttpStatusCode怎么用?PHP Exception::getHttpStatusCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getHttpStatusCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromException
/**
* @param \Exception $e
*
* @return WebhookResponse
*/
public static function fromException(\Exception $e)
{
if ($e instanceof XsollaWebhookException) {
return static::fromErrorCode($e->getXsollaErrorCode(), $e->getMessage(), $e->getHttpStatusCode());
} else {
return static::fromErrorCode('FATAL_ERROR', $e->getMessage());
}
}
示例2: __construct
/**
* @param \Exception $data
* @param int $status
* @param array $headers
*/
public function __construct(\Exception $data, $status = Response::HTTP_INTERNAL_SERVER_ERROR, $headers = array())
{
if ($data instanceof CriticalExceptionInterface) {
$status = $data->getHttpStatusCode();
} elseif ($data instanceof UncriticalExceptionInterface) {
$status = Response::HTTP_OK;
}
parent::__construct($data, $status, $headers);
$this->headers->set('X-Status-Code', $status);
}
示例3: render
/**
* The render function will take a `SymphonyErrorPage` exception and
* output a HTML page. This function first checks to see if their is a custom
* template for this exception otherwise it reverts to using the default
* `usererror.generic.php`
*
* @param Exception $e
* The Exception object
* @return string
* An HTML string
*/
public static function render(Exception $e)
{
if ($e->getTemplate() === false) {
Page::renderStatusCode($e->getHttpStatusCode());
if (isset($e->getAdditional()->header)) {
header($e->getAdditional()->header);
}
echo '<h1>Symphony Fatal Error</h1><p>' . $e->getMessage() . '</p>';
exit;
}
include $e->getTemplate();
}
示例4: prepareHttpResponse
private function prepareHttpResponse(\Exception $exception) : JsonResponse
{
$responseBodyArray = ['error-message' => 'We\'re sorry, an internal server error occurred.'];
$statusCode = $exception instanceof ExceptionWithHttpStatus ? $exception->getHttpStatusCode() : 500;
return new JsonResponse($responseBodyArray, $statusCode);
}
开发者ID:postalservice14,项目名称:sainsburys-http-service,代码行数:6,代码来源:ProductionExternalisedErrorController.php