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,40 +3,61 @@ ...@@ -3,40 +3,61 @@
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.
*
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
];
/**
* 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);
}
/** /**
* A list of the exception types that should not be reported. * Render an exception into an HTTP response.
* *
* @var array * @param \Illuminate\Http\Request $request
*/ * @param \Exception $e
protected $dontReport = [ * @return \Illuminate\Http\Response
'Symfony\Component\HttpKernel\Exception\HttpException' */
]; public function render($request, Exception $e)
{
if (config('app.debug') && class_exists('\Whoops\Run')) {
return $this->renderExceptionWithWhoops($e);
}
/** return parent::render($request, $e);
* 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);
}
/** /**
* Render an exception into an HTTP response. * Render an exception using Whoops.
* *
* @param \Illuminate\Http\Request $request * @param \Exception $e
* @param \Exception $e * @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response */
*/ protected function renderExceptionWithWhoops(Exception $e)
public function render($request, Exception $e) {
{ $whoops = new \Whoops\Run;
return parent::render($request, $e); $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