Browse code

prevent 404 handler infiniete loop

RafaƂ Szklarczyk authored on 11/06/2019 21:04:20
Showing 1 changed files
... ...
@@ -234,7 +234,7 @@ class Application{
234 234
     }
235 235
 
236 236
     public function handle404($request){
237
-        if($action = $this->router->setMatch404($request)){
237
+        if(!isset($this->router->routeInfo) && ($action = $this->router->setMatch404($request))){
238 238
             $this->runAction($action);
239 239
         }
240 240
         else{
... ...
@@ -242,7 +242,10 @@ class Application{
242 242
             echo "<pre>";
243 243
             var_dump($request);
244 244
             echo "</pre>";
245
-            throw new \Exception("The 404 (not found) route not set!");
245
+            if(isset($this->router->routeInfo))
246
+                throw new \Exception("The 404 controller or action not found!");
247
+            else
248
+                throw new \Exception("The 404 (not found) route not set!");
246 249
         }
247 250
     }
248 251