refactor: cleanup debug logs and add explicit exit in error handling flow

- Remove redundant `error_log` statements in `RouterSetup`
- Comment out unused route analysis and subdomain checks
- Add `exit()` after error rendering in `ErrorKernel`
This commit is contained in:
2025-11-03 15:59:32 +01:00
parent 0ca382f80b
commit c4a4f6de07
2 changed files with 4 additions and 19 deletions

View File

@@ -21,6 +21,8 @@ final readonly class ErrorKernel
$this->rendererFactory->getRenderer()->render(); $this->rendererFactory->getRenderer()->render();
exit();
return null; return null;
} }
} }

View File

@@ -34,45 +34,28 @@ final readonly class RouterSetup
#[Initializer(ContextType::WEB)] #[Initializer(ContextType::WEB)]
public function __invoke(): Router public function __invoke(): Router
{ {
#$routeCache = new RouteCache($this->pathProvider->getCachePath('routes.cache.php'));
$routeCount = $this->results->attributes->getCount(Route::class); $routeCount = $this->results->attributes->getCount(Route::class);
error_log("🚦 ROUTER SETUP: Route count from discovery = {$routeCount}");
if ($routeCount > 0) { if ($routeCount > 0) {
$discoveredRoutes = $this->results->attributes->get(Route::class); $discoveredRoutes = $this->results->attributes->get(Route::class);
// Direct DiscoveredAttribute API // Direct DiscoveredAttribute API
error_log("🚦 ROUTER SETUP: About to compile routes");
try { try {
$optimizedRoutes = $this->routeCompiler->compileOptimized(...$discoveredRoutes); $optimizedRoutes = $this->routeCompiler->compileOptimized(...$discoveredRoutes);
error_log("🚦 ROUTER SETUP: Routes compiled successfully");
} catch (\Throwable $e) { } catch (\Throwable $e) {
error_log("🚦 ROUTER SETUP: ERROR compiling routes: " . $e->getMessage());
error_log("🚦 ROUTER SETUP: Exception trace: " . $e->getTraceAsString());
throw $e; throw $e;
} }
// DEBUG: Log available static routes structure /*// Check GET method subdomain keys
error_log("🚦 ROUTER SETUP: About to analyze route structure");
$staticRoutes = $optimizedRoutes->getStaticRoutes();
error_log("🚦 ROUTER SETUP: HTTP Methods count = " . count($staticRoutes));
// Check GET method subdomain keys
$getSubdomainKeys = $optimizedRoutes->getSubdomainKeys(Method::GET); $getSubdomainKeys = $optimizedRoutes->getSubdomainKeys(Method::GET);
error_log("🚦 ROUTER SETUP: GET method has subdomain keys: " . json_encode($getSubdomainKeys));
// Log routes per subdomain for GET // Log routes per subdomain for GET
foreach ($getSubdomainKeys as $subdomainKey) { foreach ($getSubdomainKeys as $subdomainKey) {
$routes = $optimizedRoutes->getStaticRoutesForSubdomain(Method::GET, $subdomainKey); $routes = $optimizedRoutes->getStaticRoutesForSubdomain(Method::GET, $subdomainKey);
error_log("🚦 ROUTER SETUP: GET subdomain '{$subdomainKey}' has " . count($routes) . " routes");
foreach ($routes as $path => $route) { foreach ($routes as $path => $route) {
error_log("🚦 ROUTER SETUP: - {$path}"); error_log("🚦 ROUTER SETUP: - {$path}");
} }
} }*/
// Cache speichern
#$routeCache->save($optimizedRoutes);
} else { } else {
$optimizedRoutes = $this->routeCompiler->compileOptimized(); $optimizedRoutes = $this->routeCompiler->compileOptimized();