hideyo /
ecommerce
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Exceptions; |
||
| 4 | |||
| 5 | use Exception; |
||
| 6 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
||
| 7 | use Hideyo\Ecommerce\Framework\Services\Redirect\RedirectFacade as RedirectService; |
||
| 8 | |||
| 9 | class Handler extends ExceptionHandler |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * A list of the exception types that are not reported. |
||
| 13 | * |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | protected $dontReport = [ |
||
| 17 | // |
||
| 18 | ]; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * A list of the inputs that are never flashed for validation exceptions. |
||
| 22 | * |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | protected $dontFlash = [ |
||
| 26 | 'password', |
||
| 27 | 'password_confirmation', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Report or log an exception. |
||
| 32 | * |
||
| 33 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||
| 34 | * |
||
| 35 | * @param \Exception $exception |
||
| 36 | * @return void |
||
| 37 | */ |
||
| 38 | public function report(Exception $exception) |
||
| 39 | { |
||
| 40 | parent::report($exception); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Render an exception into an HTTP response. |
||
| 45 | * |
||
| 46 | * @param \Illuminate\Http\Request $request |
||
| 47 | * @param \Exception $exception |
||
| 48 | * @return \Illuminate\Http\Response |
||
| 49 | */ |
||
| 50 | public function render($request, Exception $exception) |
||
| 51 | { |
||
| 52 | if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { |
||
| 53 | |||
| 54 | $url = $request->url(); |
||
| 55 | |||
| 56 | RedirectService::updateClicks($url); |
||
| 57 | |||
| 58 | $findUrl = RedirectService::findByUrlAndActive($url); |
||
| 59 | |||
| 60 | if ($findUrl) { |
||
| 61 | return redirect($findUrl->redirect_url, 301); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 62 | } |
||
| 63 | |||
| 64 | return response()->view('errors.404', [], 404); |
||
| 65 | } |
||
| 66 | |||
| 67 | if ($exception instanceof \Illuminate\Session\TokenMismatchException) { |
||
| 68 | return redirect('/account/login', 301); |
||
|
0 ignored issues
–
show
|
|||
| 69 | } |
||
| 70 | |||
| 71 | if ($exception instanceof CustomException) { |
||
|
0 ignored issues
–
show
The type
App\Exceptions\CustomException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 72 | return response()->view('errors.503', [], 500); |
||
| 73 | } |
||
| 74 | |||
| 75 | return parent::render($request, $exception); |
||
| 76 | } |
||
| 77 | } |
||
| 78 |