Files
echoscoop/app/Exceptions/Handler.php
Charles Teh 88b3c9a273 Add (favicon)
Update (route): Fix missing regex combo
2023-09-25 21:39:19 +08:00

73 lines
1.6 KiB
PHP

<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Http\Request;
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)
{
}
else if ($exception instanceof AuthenticationException)
{
}
else
{
inspector()->reportException($exception);
}
//default laravel response
return parent::render($request, $exception);
}
}