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();
exit();
return null;
}
}

View File

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