| @@ -57,12 +57,17 @@ discard block | ||
| 57 | 57 | $http = $this->container->get(Http::class); | 
| 58 | 58 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); | 
| 59 | 59 | |
| 60 | -        try { | |
| 60 | + try | |
| 61 | +        { | |
| 61 | 62 | $response = $http->handle($this->initRequest()); | 
| 62 | 63 | $emitter->emit($response); | 
| 63 | -        } catch (\Throwable $e) { | |
| 64 | + } | |
| 65 | + catch (\Throwable $e) | |
| 66 | +        { | |
| 64 | 67 | $this->handleException($emitter, $e); | 
| 65 | -        } finally { | |
| 68 | + } | |
| 69 | + finally | |
| 70 | +        { | |
| 66 | 71 | $this->finalizer->finalize(false); | 
| 67 | 72 | } | 
| 68 | 73 | } | 
| @@ -83,10 +88,13 @@ discard block | ||
| 83 | 88 |      { | 
| 84 | 89 | $handler = new HtmlHandler(HtmlHandler::INVERTED); | 
| 85 | 90 | |
| 86 | -        try { | |
| 91 | + try | |
| 92 | +        { | |
| 87 | 93 | /** @var SnapshotInterface $snapshot */ | 
| 88 | 94 | $this->container->get(SnapshotterInterface::class)->register($e); | 
| 89 | -        } catch (\Throwable|ContainerExceptionInterface $se) { | |
| 95 | + } | |
| 96 | + catch (\Throwable|ContainerExceptionInterface $se) | |
| 97 | +        { | |
| 90 | 98 | // nothing to report | 
| 91 | 99 | } | 
| 92 | 100 | |
| @@ -37,7 +37,8 @@ | ||
| 37 | 37 |          $response = new Response('php://memory', $code, []); | 
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); | 
| 39 | 39 | |
| 40 | -        foreach ($this->config->getBaseHeaders() as $header => $value) { | |
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value) | |
| 41 | +        { | |
| 41 | 42 | $response = $response->withAddedHeader($header, $value); | 
| 42 | 43 | } | 
| 43 | 44 | |
| @@ -70,12 +70,18 @@ discard block | ||
| 70 | 70 | |
| 71 | 71 | /** @var Http $http */ | 
| 72 | 72 | $http = $this->container->get(Http::class); | 
| 73 | -        while ($request = $client->acceptRequest()) { | |
| 74 | -            try { | |
| 73 | + while ($request = $client->acceptRequest()) | |
| 74 | +        { | |
| 75 | + try | |
| 76 | +            { | |
| 75 | 77 | $client->respond($http->handle($request)); | 
| 76 | -            } catch (\Throwable $e) { | |
| 78 | + } | |
| 79 | + catch (\Throwable $e) | |
| 80 | +            { | |
| 77 | 81 | $this->handleException($client, $e); | 
| 78 | -            } finally { | |
| 82 | + } | |
| 83 | + finally | |
| 84 | +            { | |
| 79 | 85 | $this->finalizer->finalize(false); | 
| 80 | 86 | } | 
| 81 | 87 | } | 
| @@ -89,11 +95,14 @@ discard block | ||
| 89 | 95 |      { | 
| 90 | 96 | $handler = new HtmlHandler(HtmlHandler::INVERTED); | 
| 91 | 97 | |
| 92 | -        try { | |
| 98 | + try | |
| 99 | +        { | |
| 93 | 100 | /** @var SnapshotInterface $snapshot */ | 
| 94 | 101 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); | 
| 95 | 102 | error_log($snapshot->getMessage()); | 
| 96 | -        } catch (\Throwable|ContainerExceptionInterface $se) { | |
| 103 | + } | |
| 104 | + catch (\Throwable|ContainerExceptionInterface $se) | |
| 105 | +        { | |
| 97 | 106 | error_log((string)$e); | 
| 98 | 107 | } | 
| 99 | 108 | |
| @@ -66,7 +66,8 @@ | ||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); | 
| 68 | 68 | |
| 69 | -        if (class_exists(PSR7Client::class)) { | |
| 69 | + if (class_exists(PSR7Client::class)) | |
| 70 | +        { | |
| 70 | 71 | $kernel->addDispatcher($factory->make(RrDispacher::class)); | 
| 71 | 72 | } | 
| 72 | 73 | } |