Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\HttpKernel\DataCollector;
13
 
14
use Symfony\Component\ErrorHandler\Exception\FlattenException;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpFoundation\Response;
17
 
18
/**
19
 * @author Fabien Potencier <fabien@symfony.com>
20
 *
21
 * @final
22
 */
23
class ExceptionDataCollector extends DataCollector
24
{
25
    public function collect(Request $request, Response $response, \Throwable $exception = null)
26
    {
27
        if (null !== $exception) {
28
            $this->data = [
29
                'exception' => FlattenException::createFromThrowable($exception),
30
            ];
31
        }
32
    }
33
 
34
    public function reset()
35
    {
36
        $this->data = [];
37
    }
38
 
39
    public function hasException(): bool
40
    {
41
        return isset($this->data['exception']);
42
    }
43
 
44
    public function getException(): \Exception|FlattenException
45
    {
46
        return $this->data['exception'];
47
    }
48
 
49
    public function getMessage(): string
50
    {
51
        return $this->data['exception']->getMessage();
52
    }
53
 
54
    public function getCode(): int
55
    {
56
        return $this->data['exception']->getCode();
57
    }
58
 
59
    public function getStatusCode(): int
60
    {
61
        return $this->data['exception']->getStatusCode();
62
    }
63
 
64
    public function getTrace(): array
65
    {
66
        return $this->data['exception']->getTrace();
67
    }
68
 
69
    public function getName(): string
70
    {
71
        return 'exception';
72
    }
73
}