Skip to content

Commit

Permalink
Use a custom exception message when failing to get image size
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Oct 27, 2023
1 parent 9f94f7f commit f7e26d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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

0 comments on commit f7e26d8

Please sign in to comment.