diff --git a/packages/framework/src/Framework/Exceptions/FileNotFoundException.php b/packages/framework/src/Framework/Exceptions/FileNotFoundException.php index 417a18e3ea7..434c3c582e4 100644 --- a/packages/framework/src/Framework/Exceptions/FileNotFoundException.php +++ b/packages/framework/src/Framework/Exceptions/FileNotFoundException.php @@ -17,8 +17,8 @@ class FileNotFoundException extends Exception /** @var int */ protected $code = 404; - public function __construct(?string $path = null, ?string $customMessage = null) + public function __construct(?string $path = null, ?string $customMessage = null, ?string $appendAfterPath = '.') { - parent::__construct($customMessage ?? ($path ? sprintf('File [%s] not found.', Hyde::pathToRelative($path)) : $this->message)); + parent::__construct($customMessage ?? ($path ? sprintf('File [%s] not found'.$appendAfterPath, Hyde::pathToRelative($path)) : $this->message)); } } diff --git a/packages/framework/tests/Unit/CustomExceptionsTest.php b/packages/framework/tests/Unit/CustomExceptionsTest.php index 97927a1760b..d0ac2ae007d 100644 --- a/packages/framework/tests/Unit/CustomExceptionsTest.php +++ b/packages/framework/tests/Unit/CustomExceptionsTest.php @@ -62,6 +62,11 @@ public function testFileNotFoundExceptionWithCustomPath() $this->assertSame('foo', (new FileNotFoundException(customMessage: 'foo'))->getMessage()); } + public function testFileNotFoundExceptionWithAppendAfterPath() + { + $this->assertSame('File [foo] not found!', (new FileNotFoundException('foo', null, '!'))->getMessage()); + } + public function testRouteNotFoundExceptionWithDefaultMessage() { $this->assertSame('Route not found.', (new RouteNotFoundException())->getMessage());