Commit 84bd3ffc authored by Dan Aldridge's avatar Dan Aldridge

add whoops support

only if the package is installed & app.debug is true
parent 864c4be4
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
use Exception; use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler { class Handler extends ExceptionHandler
{
/** /**
* A list of the exception types that should not be reported. * A list of the exception types that should not be reported.
* *
...@@ -13,7 +13,6 @@ class Handler extends ExceptionHandler { ...@@ -13,7 +13,6 @@ class Handler extends ExceptionHandler {
protected $dontReport = [ protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException' 'Symfony\Component\HttpKernel\Exception\HttpException'
]; ];
/** /**
* Report or log an exception. * Report or log an exception.
* *
...@@ -36,7 +35,29 @@ class Handler extends ExceptionHandler { ...@@ -36,7 +35,29 @@ class Handler extends ExceptionHandler {
*/ */
public function render($request, Exception $e) public function render($request, Exception $e)
{ {
if (config('app.debug') && class_exists('\Whoops\Run')) {
return $this->renderExceptionWithWhoops($e);
}
return parent::render($request, $e); return parent::render($request, $e);
} }
/**
* Render an exception using Whoops.
*
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
protected function renderExceptionWithWhoops(Exception $e)
{
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
return new \Illuminate\Http\Response(
$whoops->handleException($e),
$e->getStatusCode(),
$e->getHeaders()
);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment