Skip to content

Instantly share code, notes, and snippets.

@knvpk
Created August 2, 2015 04:24
Show Gist options
  • Save knvpk/8621f1e88a764ad50016 to your computer and use it in GitHub Desktop.
Save knvpk/8621f1e88a764ad50016 to your computer and use it in GitHub Desktop.
All type of Exceptions that can be handled in laravel 5.1 Exception handler
<?php namespace App\Exceptions;
use Exception;
use Illuminate\Contracts\Validation\ValidationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
// Global exception and this must be in the last
if($e instanceof Exception)
{
// catch the global exception
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment