Skip to content

Commit bc31b56

Browse files
committed
refactor: change the way to handle pagenotfound exception.
1 parent c780a23 commit bc31b56

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

system/Router/AutoRouter.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public function getRoute(string $uri, string $httpVerb): array
159159
$file = APPPATH . 'Controllers/' . $this->directory . $controllerName . '.php';
160160
if (is_file($file)) {
161161
include_once $file;
162+
} else {
163+
throw PageNotFoundException::forControllerNotFound($this->controller, $this->method);
162164
}
163165

164166
// Ensure the controller stores the fully-qualified class name
@@ -174,11 +176,6 @@ public function getRoute(string $uri, string $httpVerb): array
174176
);
175177
}
176178

177-
// Check if the controller exists.
178-
if (! class_exists($this->controller, true) || $this->method[0] === '_') {
179-
throw PageNotFoundException::forControllerNotFound($this->controller, $this->method);
180-
}
181-
182179
return [$this->directory, $this->controllerName(), $this->methodName(), $params];
183180
}
184181

0 commit comments

Comments
 (0)