本文整理汇总了PHP中Illuminate\Foundation\Exceptions\Handler::renderHttpException方法的典型用法代码示例。如果您正苦于以下问题:PHP Handler::renderHttpException方法的具体用法?PHP Handler::renderHttpException怎么用?PHP Handler::renderHttpException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Foundation\Exceptions\Handler
的用法示例。
在下文中一共展示了Handler::renderHttpException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderHttpException
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
if (view()->exists("errors.{$status}")) {
return response()->view("errors.{$status}", ['message' => $e->getMessage()], $status);
}
return parent::renderHttpException($e);
}
示例2: renderHttpException
protected function renderHttpException(HttpException $exc)
{
if (\Request::ajax()) {
/** @var HttpException $exc */
return $this->convertHttpExceptionToJsonResponse($exc);
} else {
return parent::renderHttpException($exc);
}
}
示例3: renderHttpException
/**
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e) : Response
{
if (!request()->ajax() && !request()->wantsJson()) {
return parent::renderHttpException($e);
}
$code = $e->getStatusCode();
$message = $this->getHttpMessage($code);
return response()->json(["code" => $code, "message" => $message], $code, $e->getHeaders());
}
示例4: renderHttpException
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
if (view()->exists($this->pathErrors . $status)) {
return response()->view($this->pathErrors . $status, ['exception' => $e], $status, $e->getHeaders());
} else {
return parent::renderHttpException($e);
}
}