66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Illuminate\Auth\AuthenticationException;
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
use Throwable;
|
|
|
|
class Handler extends ExceptionHandler
|
|
{
|
|
/**
|
|
* The list of the inputs that are never flashed to the session on 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 $exception) {
|
|
//
|
|
|
|
});
|
|
|
|
$this->renderable(function (NotFoundHttpException $e, $request) {
|
|
if ($request->is('api/*')) {
|
|
return response()->json([
|
|
'status' => -1,
|
|
], 404);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Render an exception into an HTTP response.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Exception $exception
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function render($request, Throwable $exception)
|
|
{
|
|
|
|
if ($exception instanceof NotFoundHttpException) {
|
|
|
|
} elseif ($exception instanceof AuthenticationException) {
|
|
|
|
} else {
|
|
inspector()->reportException($exception);
|
|
}
|
|
|
|
//default laravel response
|
|
return parent::render($request, $exception);
|
|
}
|
|
}
|