本文整理匯總了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);
}
}