Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.00% covered (success)
90.00%
9 / 10
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Handler
90.00% covered (success)
90.00%
9 / 10
50.00% covered (danger)
50.00%
1 / 2
6.04
0.00% covered (danger)
0.00%
0 / 1
 register
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 render
87.50% covered (warning)
87.50%
7 / 8
0.00% covered (danger)
0.00%
0 / 1
5.05
1<?php
2
3namespace App\Exceptions;
4
5use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6use Illuminate\Http\Exceptions\ThrottleRequestsException;
7use Throwable;
8
9class Handler extends ExceptionHandler
10{
11    /**
12     * A list of the exception types that are not reported.
13     *
14     * @var array<int, class-string<Throwable>>
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<int, string>
24     */
25    protected $dontFlash = [
26        'current_password',
27        'password',
28        'password_confirmation',
29    ];
30
31    /**s
32     * Register the exception handling callbacks for the application.
33     *
34     * @return void
35     */
36    public function register()
37    {
38        $this->reportable(function (Throwable $e) {
39            //
40        });
41    }
42
43    /**
44     * @param $request
45     * @param Throwable $exception
46     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
47     * @throws Throwable
48     */
49    public function render($request, Throwable $exception)
50    {
51        if ($this->isHttpException($exception))
52        {
53            if ($exception->getStatusCode() == 404)
54            {
55                return response()->view('errors.404', [], 404);
56            }
57            if ($exception->getStatusCode() == 500)
58            {
59                return response()->view('errors.500', [], 500);
60            }
61            if ($exception->getStatusCode() == 429)
62            {
63                return response()->view('errors.429', [], 429);
64            }
65        }
66
67        return parent::render($request, $exception);
68    }
69}