Handler::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace Core\Exceptions;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\ModelNotFoundException;
7
use Symfony\Component\HttpKernel\Exception\HttpException;
8
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
10
11
class Handler extends ExceptionHandler
12
{
13
    /**
14
     * A list of the exception types that should not be reported.
15
     *
16
     * @var array
17
     */
18
    protected $dontReport = [
19
        HttpException::class,
20
        ModelNotFoundException::class,
21
    ];
22
23
    /**
24
     * Report or log an exception.
25
     *
26
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
27
     *
28
     * @param  \Exception $e
29
     * @return void
30
     */
31
    public function report(Exception $e)
32
    {
33
        return parent::report($e);
34
    }
35
36
    /**
37
     * Render an exception into an HTTP response.
38
     *
39
     * @param  \Illuminate\Http\Request $request
40
     * @param  \Exception $e
41
     * @return \Illuminate\Http\Response
42
     */
43
    public function render($request, Exception $e)
44
    {
45
        if ($e instanceof ModelNotFoundException) {
46
            $e = new NotFoundHttpException($e->getMessage(), $e);
47
        }
48
49
        return parent::render($request, $e);
50
    }
51
}
52