I've modified Exceptions/Handler.php to:
<?php namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
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)
{
if($e instanceof NotFoundHttpException)
{
return response()->view('errors/404');
}
elseif ($e instanceof ErrorException) {
return response()->view('errors/404');
}
elseif ($e instanceof ModelNotFoundException) {
return response()->view('error_log(message)ors/404');
}
elseif($e instanceof PDOException)
{
return Redirect::to('install.php');
}
elseif($e instanceof QueryException)
{
return Redirect::to('install.php');
}
else return response()->view('errors/error');
}
trying to redirect to installation whenever application makes PDOException, but I'm just getting general error view (errors/error - from the last line of the code above).
Is there a way to cach specifically PDOException error?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire