%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/admin1/app/Exceptions/ |
Upload File : |
<?php
namespace App\Exceptions;
use Froiden\RestAPI\Exceptions\ApiException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Facades\App;
use Illuminate\Validation\ValidationException;
use Illuminate\Routing\Exceptions\InvalidSignatureException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
ApiException::class
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->renderable(function (ApiException $e, $request) {
return response()->json($e, 403);
});
$this->reportable(function (Throwable $e) {
//
});
$this->renderable(function (\Exception $e) {
if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) {
return redirect()->route('login');
}
});
$this->renderable(function (InvalidSignatureException $e) {
return response()->view('errors.link-expired', [], 403);
});
}
public function report(Throwable $exception)
{
if (app()->bound('sentry') && $this->shouldReport($exception) && config('services.sentry.enabled')) {
app('sentry')->captureException($exception);
}
parent::report($exception);
}
/**
* Convert a validation exception into a JSON response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Validation\ValidationException $exception
* @return \Illuminate\Http\JsonResponse
*/
protected function invalidJson($request, ValidationException $exception)
{
return response()->json([
'message' => __('validation.givenDataInvalid'),
'errors' => $exception->errors(),
], $exception->status);
}
public function render($request, Throwable $exception)
{
if ($exception instanceof TokenMismatchException) {
return redirect(route('login'))->with('message', 'You page session expired. Please try again');
}
return parent::render($request, $exception);
}
}