Skip to content

Commit

Permalink
refactor: change the way to handle pagenotfound exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
ping-yee committed Oct 9, 2023
1 parent c780a23 commit bc31b56
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions system/Router/AutoRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public function getRoute(string $uri, string $httpVerb): array
$file = APPPATH . 'Controllers/' . $this->directory . $controllerName . '.php';
if (is_file($file)) {
include_once $file;
} else {
throw PageNotFoundException::forControllerNotFound($this->controller, $this->method);
}

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

// Check if the controller exists.
if (! class_exists($this->controller, true) || $this->method[0] === '_') {
throw PageNotFoundException::forControllerNotFound($this->controller, $this->method);
}

return [$this->directory, $this->controllerName(), $this->methodName(), $params];
}

Expand Down

0 comments on commit bc31b56

Please sign in to comment.