diff --git a/public/index.php b/public/index.php index 7fef304..11d35f5 100644 --- a/public/index.php +++ b/public/index.php @@ -76,19 +76,24 @@ if ($uri === '/' || $uri === '/index.php') { header('Content-Type: application/json'); echo json_encode(['status' => 'ok', 'version' => '2027.1']); } elseif (preg_match('/^\/round\/(\d+)$/', $uri, $matches)) { - $roundId = $matches[1]; - $round = Round::getById($roundId); + try { + $roundId = $matches[1]; + $round = Round::getById($roundId); - if (!$round) { - http_response_code(404); - echo "404 Not Found: Runde nicht gefunden."; - exit; + if (!$round) { + http_response_code(404); + echo "404 Not Found: Runde nicht gefunden."; + exit; + } + + $games = Game::getGamesByRound($roundId); + + // Lade das View-Template für die Rundenansicht + require __DIR__ . '/../src/Views/round.php'; + } catch (Exception $e) { + http_response_code(500); + echo "
Datenbankfehler: " . htmlspecialchars($e->getMessage()) . "
"; } - - $games = Game::getGamesByRound($roundId); - - // Lade das View-Template für die Rundenansicht - require __DIR__ . '/../src/Views/round.php'; } else { http_response_code(404); echo "404 Not Found";