Completed
Push — master ( 342745...4baf67 )
by wen
15:00
created

Handler::report()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Sco\Admin\Exceptions;
4
5
use Exception;
6
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
7
8
class Handler implements ExceptionHandlerContract
9
{
10
    protected $parentHandler;
11
12
    public function __construct(ExceptionHandlerContract $parentHandler)
13
    {
14
        $this->parentHandler = $parentHandler;
15
    }
16
17
    /**
18
     * Report or log an exception.
19
     *
20
     * @param  \Exception $exception
21
     *
22
     * @return void
23
     * @throws \Exception
24
     */
25
    public function report(Exception $exception)
26
    {
27
        $this->parentHandler->report($exception);
28
    }
29
30
    /**
31
     * Render an exception into a response.
32
     *
33
     * @param  \Illuminate\Http\Request $request
34
     * @param  \Exception               $exception
35
     *
36
     * @return \Symfony\Component\HttpFoundation\Response
37
     */
38
    public function render($request, Exception $exception)
39
    {
40
        if ($exception instanceof AdminHttpException) {
41
            return response($exception->getMessage(), $exception->getStatusCode());
42
        }
43
44
        return $this->parentHandler->render($request, $exception);
45
    }
46
47
    /**
48
     * Render an exception to the console.
49
     *
50
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
51
     * @param  \Exception                                        $exception
52
     *
53
     * @return void
54
     */
55
    public function renderForConsole($output, Exception $exception)
56
    {
57
        $this->parentHandler->renderForConsole($output, $exception);
58
    }
59
}
60