for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace CheatCodes\LaravelWhoops;
use App\Exceptions\Handler;
use Exception;
use Request;
use Whoops\Run as Whoops;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Handler\JsonResponseHandler;
class WhoopsExceptionHandler extends Handler
{
/**
* Get the Whoops Handler instance to use
*
* @return \Whoops\Handler\Handler
*/
protected function getWhoopsHandler()
$ajaxResponse = (Request::ajax() || Request::wantsJson());
return $ajaxResponse ? new JsonResponseHandler() : new PrettyPageHandler();
}
* Create a Whoops response for the given exception
* @param Exception $e
* @return \Illuminate\Http\Response
protected function convertExceptionToWhoops(Exception $e)
$whoops = new Whoops();
$whoops->pushHandler($this->getWhoopsHandler());
$statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500;
$headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : [];
return response()->make($whoops->handleException($e), $statusCode, $headers);
$e
object<Exception>
object<Throwable>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
* Create the default or a Whoops response for the given exception
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
protected function convertExceptionToResponse(Exception $e)
return config('app.debug')
? $this->convertExceptionToWhoops($e)
: parent::convertExceptionToResponse($e);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: