Last active
August 29, 2015 14:27
-
-
Save emtudo/4dc8f5fc0e39dd5874a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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