Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
5 changes: 5 additions & 0 deletions packages/framework/tests/Unit/CustomExceptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down