REFACTORING: move content update and create logic into separate interactions
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\CMS\Exceptions\Validation\ValidationFailedException;
|
||||
use Exception;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
@@ -29,7 +30,8 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
@@ -40,15 +42,21 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof TokenMismatchException){
|
||||
if ($e instanceof TokenMismatchException) {
|
||||
//redirect to form an example of how I handle mine
|
||||
return redirect($request->fullUrl())->with('error', trans('validation.csrf'));
|
||||
} elseif ($e instanceof ValidationFailedException) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->withErrors($e->getValidator());
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
|
||||
Reference in New Issue
Block a user