Skip to content

Commit

Permalink
clean up exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 6, 2017
1 parent c5add7a commit 758392c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
//
];

/**
Expand Down Expand Up @@ -56,10 +51,8 @@ public function render($request, Exception $exception)
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}

return redirect()->guest(route('login'));
return $request->expectsJson()
? response()->json(['error' => 'Unauthenticated.'], 401)
: redirect()->guest(route('login'));
}
}

0 comments on commit 758392c

Please sign in to comment.