Files
sccs_laravel/app/Exceptions/Handler.php
2025-11-04 16:23:40 +05:00

54 lines
1.3 KiB
PHP

<?php
namespace App\Exceptions;
use App\Traits\ApiResponseHelper;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;
class Handler extends ExceptionHandler
{
use ApiResponseHelper;
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
// \Illuminate\Database\Eloquent\ModelNotFoundException::class
];
/**
* 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) {
//
});
$this->renderable(function (NotFoundHttpException $exception, $request) {
if($request->is('api/*')) {
return $this->apiResponse(false, 'Whoops! Your desired record could not be found.');
}
return response()->view('content.error', [], 404);
});
}
}