Files
lsky-pro/app/Exceptions/Handler.php
T
Wisp X 93f7e111ba 🐛 修复 BUG
2022-02-16 15:52:00 +08:00

53 lines
1.2 KiB
PHP

<?php
namespace App\Exceptions;
use App\Http\Api;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
use Api;
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
protected function unauthenticated($request, AuthenticationException $exception)
{
return $this->shouldReturnJson($request, $exception)
? $this->error($exception->getMessage())->setStatusCode(401)
: redirect()->guest($exception->redirectTo() ?? route('login'));
}
}