summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2023-12-26 10:00:49 +0100
committerDaniel Weipert <git@mail.dweipert.de>2023-12-26 10:00:49 +0100
commit2d814b1e433ae96b36579b2fa882e9a17652e7a5 (patch)
tree9f5dbfba8ea7520af2b9b3035e31591feacb5a45
parent4d45cc64499de2de6f758ff7c6f33d1fdd06f73e (diff)
[PhpServer] correct exception handlingv1.0.0
-rw-r--r--src/Server/RequestHandlers/PhpServer.php20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/Server/RequestHandlers/PhpServer.php b/src/Server/RequestHandlers/PhpServer.php
index 5447f72..c3ded4d 100644
--- a/src/Server/RequestHandlers/PhpServer.php
+++ b/src/Server/RequestHandlers/PhpServer.php
@@ -19,23 +19,19 @@ class PhpServer extends DocumentServer
}
if (is_file($documentPath) && str_ends_with($documentPath, '.php')) {
- ob_start();
try {
+ ob_start();
include $documentPath;
- } catch (\Throwable $exception) {
- echo <<<EXCEPTION
-
- ```
- $exception
- ```
+ $content = ob_get_clean();
- EXCEPTION;
+ $response->setStatusCode(Status::SUCCESS);
+ $response->setBody($content);
+ $response->setMeta('text/gemini; charset=utf-8');
+ } catch (\Throwable $exception) {
+ $response->setStatusCode(Status::PERMANENT_FAILURE);
+ $response->setMeta($exception);
}
- $content = ob_get_clean();
- $response->setBody($content);
- $response->setStatusCode(Status::SUCCESS);
- $response->setMeta('text/gemini; charset=utf-8');
} else {
return parent::__invoke($response, $request);
}