Skip to content

Instantly share code, notes, and snippets.

@emtudo
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emtudo/4dc8f5fc0e39dd5874a6 to your computer and use it in GitHub Desktop.
Save emtudo/4dc8f5fc0e39dd5874a6 to your computer and use it in GitHub Desktop.
<?php namespace App\Exceptions;
use Exception;
use Illuminate\Http\Response;
use App\Exceptions\Handler as BaseExceptionHandler;
class WhoopsHandler extends BaseExceptionHandler {
/**
* Render an exception into a response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $e) {
$whoops = new \Whoops\Run;
if ($request->ajax())
{
$whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler());
}
else
{
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
}
return new Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment