0
I don’t know why errors aren’t rendered in my project, it just doesn’t go through the Handler method.
bootstrap/app.php
<?php
$app = new Illuminate\Foundation\Application(
realpath(__DIR__ . '/../')
);
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
return $app;
app/Exception/Handler.php.php
namespace App\Exceptions;
use Exception;
use GrahamCampbell\Exceptions\ExceptionHandler as ExceptionHandler;
class Handler extends ExceptionHandler {
protected $dontReport = [
\Symfony\Component\HttpKernel\Exception\HttpException::class,
];
public function report(Exception $e) {
return parent::report($e);
}
public function render($request, Exception $e) {
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
$whoops = new \Whoops\Run;
if ($request->ajax()) {
$whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler());
} else {
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
}
return new \Illuminate\Http\Response(
$whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()
);
}
I have tried to do several ways, when the error is 404 and I put this excerpt in Handler, it works:
if (method_exists($e, 'getStatusCode') && $e->getStatusCode() == 404)
return redirect('/erro');
return parent::render($request, $e);
However I am trying to divide by 0 to force the error and in no way works in the first example, other errors I’ve had during development are also not treated.
Original do Laravel
– Kenny Rafael
I’m just forcing to test, in fact no error is rendered...hehe
– Kenny Rafael
I actually want to render the error with "filp/Whoops", which I have just discovered is no longer native from Laravel 5.
– Kenny Rafael
Precisely, my problem is not with the 404 errors, this are treated well, I want to render the errors so I can debug...
– Kenny Rafael
https://camo.githubusercontent.com/31a4e1410e740fd0ccda128cbcab8723f45e7e73/687474703a2f2f692e696d6775722e636f6d2f305651706539362e706e67
– Kenny Rafael
Kenny I downloaded the Whoops and put in my Routes so to test
Route::get('/others/blog/', function () {
 abort(500);
 return 'Olá';
});
and it worked... How is the test you are doing with error 500? Note that mine . env is like thisAPP_ENV=local
APP_DEBUG=true
(another detail am using version 2.0, you are using 1.1?)– Guilherme Nascimento
My . env is like this tmb, and the version is also 2.0
– Kenny Rafael
And how are you sending error 500? I did a test on the index so too:
Route::get('/', function () { abort(500); return 'Olá'; });
and it worked.– Guilherme Nascimento
I did a division by zero in an action...
– Kenny Rafael
I tried an abortion(500); but neither did I
– Kenny Rafael
I get it, you want to intercept the Exceptions, here it worked normal, how much your project weighs?
– Guilherme Nascimento
then... 10gb... = P
– Kenny Rafael
I tested here division by 0 and it worked: http://i.stack.Imgur.com/Ooxhn.png - I can only assume that it was some mistake of yours, call me in the chat Stack Overflow tomorrow.
– Guilherme Nascimento