Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a custom exception message when failing to get image size #1399

Merged
merged 3 commits into from
Oct 27, 2023
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
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This serves two purposes:
- Updated dropdown navigation menus to support setting priority in config in https://github.com/hydephp/develop/pull/1387 (fixing https://github.com/hydephp/hyde/issues/229)
- Updated the vendor publish command to support parent Laravel Prompts implementation in https://github.com/hydephp/develop/pull/1388
- Fixed wrong version constant in https://github.com/hydephp/develop/pull/1391
- Fixed improperly formatted exception message in https://github.com/hydephp/develop/pull/1399

### Security
- in case of vulnerabilities.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected function getContentLengthForLocalImage(): int
$storagePath = Hyde::mediaPath($this->source);

if (! file_exists($storagePath)) {
throw new FileNotFoundException(sprintf('Image at %s does not exist', Hyde::pathToRelative($storagePath)));
throw new FileNotFoundException(customMessage: sprintf('Featured image [%s] not found.', Hyde::pathToRelative($storagePath)));
}

return filesize($storagePath);
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Unit/FeaturedImageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function testGetContentLength()
public function testFeaturedImageGetContentLengthWithNoSource()
{
$this->expectException(FileNotFoundException::class);
$this->expectExceptionMessage('Image at _media/foo does not exist');
$this->expectExceptionMessage('Featured image [_media/foo] not found.');

$image = new FeaturedImage('_media/foo', ...$this->defaultArguments());
$this->assertEquals(0, $image->getContentLength());
Expand Down
Loading