Skip to content

Instantly share code, notes, and snippets.

@oliveiramiguel
Last active March 25, 2016 22:21
Show Gist options
  • Select an option

  • Save oliveiramiguel/5c1df23ba49453982ee9 to your computer and use it in GitHub Desktop.

Select an option

Save oliveiramiguel/5c1df23ba49453982ee9 to your computer and use it in GitHub Desktop.
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Http\Exception\PostTooLargeException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\MessageBag;
class Handler extends ExceptionHandler
{
protected $dontReport = [
HttpException::class,
ModelNotFoundException::class,
];
public function report(Exception $e)
{
return parent::report($e);
}
public function render($request, Exception $e)
{
if ($e instanceof PostTooLargeException) {
$errors = new MessageBag(['post_too_large' => ['Erro: o arquivo enviado é muito grande para ser processado.']]);
return back()->withErrors($errors);
}
return parent::render($request, $e);
}
}
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\Illuminate\Foundation\Http\Middleware\VerifyPostSize::class,
\App\Http\Middleware\VerifyCsrfToken::class,
];
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment