Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace NunoMaduro\Collision\Adapters\Laravel;
6
 
7
use Illuminate\Contracts\Container\Container;
8
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
9
use NunoMaduro\Collision\Contracts\Provider as ProviderContract;
10
use Symfony\Component\Console\Exception\ExceptionInterface as SymfonyConsoleExceptionInterface;
11
use Throwable;
12
 
13
/**
14
 * @internal
15
 */
16
final class ExceptionHandler implements ExceptionHandlerContract
17
{
18
    /**
19
     * Holds an instance of the application exception handler.
20
     *
21
     * @var \Illuminate\Contracts\Debug\ExceptionHandler
22
     */
23
    protected $appExceptionHandler;
24
 
25
    /**
26
     * Holds an instance of the container.
27
     *
28
     * @var \Illuminate\Contracts\Container\Container
29
     */
30
    protected $container;
31
 
32
    /**
33
     * Creates a new instance of the ExceptionHandler.
34
     */
35
    public function __construct(Container $container, ExceptionHandlerContract $appExceptionHandler)
36
    {
37
        $this->container = $container;
38
        $this->appExceptionHandler = $appExceptionHandler;
39
    }
40
 
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function report(Throwable $e)
45
    {
46
        $this->appExceptionHandler->report($e);
47
    }
48
 
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function render($request, Throwable $e)
53
    {
54
        return $this->appExceptionHandler->render($request, $e);
55
    }
56
 
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function renderForConsole($output, Throwable $e)
61
    {
62
        if ($e instanceof SymfonyConsoleExceptionInterface) {
63
            $this->appExceptionHandler->renderForConsole($output, $e);
64
        } else {
65
            /** @var \NunoMaduro\Collision\Contracts\Provider $provider */
66
            $provider = $this->container->make(ProviderContract::class);
67
 
68
            $handler = $provider->register()
69
                ->getHandler()
70
                ->setOutput($output);
71
 
72
            $handler->setInspector((new Inspector($e)));
73
 
74
            $handler->handle();
75
        }
76
    }
77
 
78
    /**
79
     * Determine if the exception should be reported.
80
     *
81
     * @return bool
82
     */
83
    public function shouldReport(Throwable $e)
84
    {
85
        return $this->appExceptionHandler->shouldReport($e);
86
    }
87
}