2016-11-21 44 views

回答

2

所有HTTP異常由renderHttpException()方法內\Illuminate\Foundation\Exceptions\Handler.php

/** 
* 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}", ['exception' => $e], $status, $e->getHeaders()); 
    } else { 
     return $this->convertExceptionToResponse($e); 
    } 
} 

處理我假設你想顯示爲503異常的自定義視圖。在這種情況下,只需在resources/views/errors中創建自己的503.blade.php文件即可。