Skip to content

Commit

Permalink
Merge pull request #75 from jdecool/fix-exceptions
Browse files Browse the repository at this point in the history
Fix exception code when file not found
  • Loading branch information
jdecool committed Jun 1, 2015
2 parents 92c8c6e + 1ba0115 commit 4105233
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/PHPImageWorkshop/ImageWorkshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class ImageWorkshop
*/
public static function initFromPath($path, $fixOrientation = false)
{
if (!file_exists($path)) {
throw new ImageWorkshopException(sprintf('File "%s" not exists.', $path), static::ERROR_IMAGE_NOT_FOUND);
}

if (false === ($imageSizeInfos = @getImageSize($path))) {
throw new ImageWorkshopException('Can\'t open the file at "'.$path.'" : file is not readable, did you check permissions (755 / 777) ?', static::ERROR_NOT_READABLE_FILE);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageWorkshopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testInitFromPath()

// test 3

$this->setExpectedException('PHPImageWorkshop\Exception\ImageWorkshopException');
$this->setExpectedException('PHPImageWorkshop\Exception\ImageWorkshopException', '', ImageWorkshop::ERROR_IMAGE_NOT_FOUND);
$layer = ImageWorkshop::initFromPath('fakePath');
}

Expand Down

0 comments on commit 4105233

Please sign in to comment.