From 8a533c80055342ca14be2d10bc78c9962880e426 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Tue, 4 Feb 2025 14:50:07 -0500 Subject: [PATCH] Remove 404 exception --- src/SegmentRouterTrait.php | 2 +- tests/test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SegmentRouterTrait.php b/src/SegmentRouterTrait.php index 7266a8c..0444c94 100644 --- a/src/SegmentRouterTrait.php +++ b/src/SegmentRouterTrait.php @@ -80,7 +80,7 @@ trait SegmentRouterTrait $carry[] = $segment; $node = $node[':x']; } else { - throw new \Exception('404'); + return ['code' => 404, 'handler' => null, 'params' => null]; } return $carry; }, diff --git a/tests/test.php b/tests/test.php index 3c0f945..ee3c66d 100644 --- a/tests/test.php +++ b/tests/test.php @@ -88,7 +88,7 @@ for ($i = 0; $i < 10; $i++) { $res = SegmentRouter::lookup($routes, $method, $uri); if ($res['code'] !== 200) { - echo "Failed to handle request for $uri - $res\n"; + echo "Failed to handle request for $uri - " . json_encode($res) . "\n"; exit(1); } $res['handler'](...$res['params']);