Skip to content

Commit 9ddbf09

Browse files
author
Greg Bowler
committed
Throw exception when path not found
1 parent 88f6b7b commit 9ddbf09

6 files changed

+17
-6
lines changed

src/Exception.php

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/Lifecycle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public static function createCoreObjects():void {
8181
* @see https://php.gt/globals
8282
*/
8383
public static function protectGlobals() {
84+
// TODO: Extract into the individual global-wrapping classes.
8485
Protection::deregisterGlobals();
8586
Protection::overrideGlobals();
8687
}

src/Route/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(RequestInterface $request, string $documentRoot) {
2323
*/
2424
abstract public function getBaseViewLogicPath():string;
2525

26-
public function getViewFile(string $uriPath):?string {
26+
public function getViewFile(string $uriPath):string {
2727
$baseViewLogicPath = $this->getBaseViewLogicPath();
2828
$viewFileSubPath = $this->getViewLogicSubPath($uriPath);
2929
$viewFileBaseName = self::DEFAULT_BASENAME;
@@ -56,7 +56,7 @@ public function getViewFile(string $uriPath):?string {
5656
return $fileInfo->getRealPath();
5757
}
5858

59-
return null;
59+
throw new ViewFileNotFoundException($uriPath);
6060
}
6161

6262
/**
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
namespace Gt\WebEngine\Route;
3+
4+
use Gt\WebEngine\WebEngineException;
5+
6+
class RouterWebEngineException extends WebEngineException {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
namespace Gt\WebEngine\Route;
3+
4+
class ViewFileNotFoundException extends RouterWebEngineException {}

src/WebEngineException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
namespace Gt\WebEngine;
3+
4+
class WebEngineException extends \Exception {}

0 commit comments

Comments
 (0)