我只是把Laravel 4.2升级到Laravel 5.0。在App/Exception/Handler.php文件中,我有如下代码:
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
...
return parent::report($e);
}我想知道如何获得错误代码(500,404,.)report方法中的响应。
谢谢大家!
发布于 2017-11-30 14:18:50
你可以试试这个:
// If this exception is an instance of HttpException
if ($this->isHttpException($e)) {
// Grab the HTTP status code from the Exception
$status = $e->getStatusCode();
}发布于 2017-11-30 14:17:49
if ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException)
{
$e->getStatusCode();
}https://stackoverflow.com/questions/47575487
复制相似问题