Files
nl-jqrl-api/app/Exceptions/Handler.php

66 lines
1.8 KiB
PHP
Raw Normal View History

<?php
namespace App\Exceptions;
2014-11-18 22:48:38 -06:00
use Exception;
2016-07-10 16:35:03 -05:00
use Illuminate\Auth\AuthenticationException;
2014-11-18 22:48:38 -06:00
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
2015-02-22 20:47:03 -06:00
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
2016-07-10 11:35:03 -05:00
\Illuminate\Auth\AuthenticationException::class,
2016-05-26 10:00:14 -05:00
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
2016-08-23 15:14:23 +02:00
\Illuminate\Session\TokenMismatchException::class,
2016-05-26 10:00:14 -05:00
\Illuminate\Validation\ValidationException::class,
2015-02-22 20:47:03 -06:00
];
2014-12-02 17:21:16 -06:00
2015-02-22 20:47:03 -06:00
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
2015-02-22 20:47:03 -06:00
* @return void
*/
public function report(Exception $exception)
2015-02-22 20:47:03 -06:00
{
parent::report($exception);
2015-02-22 20:47:03 -06:00
}
2014-11-18 22:48:38 -06:00
2015-02-22 20:47:03 -06:00
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
2015-02-22 20:47:03 -06:00
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
2015-02-22 20:47:03 -06:00
{
return parent::render($request, $exception);
2015-02-22 20:47:03 -06:00
}
2016-05-26 10:00:14 -05:00
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
2016-05-26 10:00:14 -05:00
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
2016-05-26 10:00:14 -05:00
{
2016-06-22 08:48:58 -05:00
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
2016-05-26 10:00:14 -05:00
}
return redirect()->guest(route('login'));
2016-05-26 10:00:14 -05:00
}
2014-11-18 22:48:38 -06:00
}