Completed
Push — master ( f2f6fa...1beb9c )
by claudio
03:43
created

Handler::report()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace plunner\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 4
    public function report(Exception $e)
32
    {
33 4
        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 4
    public function render($request, Exception $e)
44
    {
45 4
        if ($e instanceof ModelNotFoundException) {
46 1
            $e = new NotFoundHttpException($e->getMessage(), $e);
47 1
        }
48
49 4
        return parent::render($request, $e);
50
    }
51
}
52