Handler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 3
dl 0
loc 41
rs 10

2 Methods

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