Skip to content

Commit 507977a

Browse files
authored
Update RequestLoop.php
1 parent efe15f3 commit 507977a

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/Loop/RequestLoop.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use React\Http\Response;
1616
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1717
use Symfony\Component\HttpFoundation\Request;
18-
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
18+
use Symfony\Component\HttpKernel\Exception\HttpException;
1919

2020
class RequestLoop
2121
{
@@ -95,31 +95,31 @@ public function request(ServerRequestInterface $request)
9595
$sfRequest->server->set('REQUEST_URI', $path);
9696

9797
try {
98-
/** @var \Symfony\Component\HttpFoundation\Response $sfResponse */
99-
$sfResponse = $this->kernel->handle($sfRequest);
100-
101-
$this->kernel->terminate($sfRequest, $sfResponse);
102-
103-
return new Response(
104-
$sfResponse->getStatusCode(),
105-
$sfResponse->headers->all(),
106-
$sfResponse->getContent()
107-
);
108-
} catch (NotFoundHttpException $e) {
109-
return new Response(
110-
404,
111-
[],
112-
'404: Page not found'
113-
);
114-
} catch (\Throwable $e) {
115-
$this->consoleOutput->getErrorOutput()->writeln(['ERROR: ' . $e->getMessage(), $e->getTraceAsString()]);
116-
117-
return new Response(
118-
500,
119-
[],
120-
'Internal server error'
121-
);
122-
}
98+
/** @var \Symfony\Component\HttpFoundation\Response $sfResponse */
99+
$sfResponse = $this->kernel->handle($sfRequest);
100+
101+
$this->kernel->terminate($sfRequest, $sfResponse);
102+
103+
return new Response(
104+
$sfResponse->getStatusCode(),
105+
$sfResponse->headers->all(),
106+
$sfResponse->getContent()
107+
);
108+
} catch (HttpException $e) {
109+
return new Response(
110+
$e->getStatusCode(),
111+
[],
112+
$e->getStatusCode() . ': ' . $e->getMessage()
113+
);
114+
} catch (\Throwable $e) {
115+
$this->consoleOutput->getErrorOutput()->writeln(['ERROR: ' . $e->getMessage(), $e->getTraceAsString()]);
116+
117+
return new Response(
118+
500,
119+
[],
120+
'Internal server error'
121+
);
122+
}
123123
}
124124

125125
/**

0 commit comments

Comments
 (0)