Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Routing;
4
 
5
use Illuminate\Contracts\Debug\ExceptionHandler;
6
use Illuminate\Contracts\Support\Responsable;
7
use Illuminate\Http\Request;
8
use Illuminate\Pipeline\Pipeline as BasePipeline;
9
use Throwable;
10
 
11
/**
12
 * This extended pipeline catches any exceptions that occur during each slice.
13
 *
14
 * The exceptions are converted to HTTP responses for proper middleware handling.
15
 */
16
class Pipeline extends BasePipeline
17
{
18
    /**
19
     * Handles the value returned from each pipe before passing it to the next.
20
     *
21
     * @param  mixed  $carry
22
     * @return mixed
23
     */
24
    protected function handleCarry($carry)
25
    {
26
        return $carry instanceof Responsable
27
            ? $carry->toResponse($this->getContainer()->make(Request::class))
28
            : $carry;
29
    }
30
 
31
    /**
32
     * Handle the given exception.
33
     *
34
     * @param  mixed  $passable
35
     * @param  \Throwable  $e
36
     * @return mixed
37
     *
38
     * @throws \Throwable
39
     */
40
    protected function handleException($passable, Throwable $e)
41
    {
42
        if (! $this->container->bound(ExceptionHandler::class) ||
43
            ! $passable instanceof Request) {
44
            throw $e;
45
        }
46
 
47
        $handler = $this->container->make(ExceptionHandler::class);
48
 
49
        $handler->report($e);
50
 
51
        $response = $handler->render($passable, $e);
52
 
53
        if (is_object($response) && method_exists($response, 'withException')) {
54
            $response->withException($e);
55
        }
56
 
399 lars 57
        return $this->handleCarry($response);
148 lars 58
    }
59
}