diff --git a/src/Helpers/TransferHelper.php b/src/Helpers/TransferHelper.php index 83b0829a..cd6353e0 100644 --- a/src/Helpers/TransferHelper.php +++ b/src/Helpers/TransferHelper.php @@ -13,7 +13,14 @@ class TransferHelper } set_time_limit(0); - $srcHandle = fopen($srcUrl, 'rb'); + try + { + $srcHandle = fopen($srcUrl, 'rb'); + } + catch (Exception $e) + { + throw new SimpleException('Cannot open URL for reading: ' . $e->getMessage()); + } if (!$srcHandle) throw new SimpleException('Cannot open URL for reading'); diff --git a/src/ThumbnailGenerators/SmartThumbnailGenerator.php b/src/ThumbnailGenerators/SmartThumbnailGenerator.php index a884ecc5..47d83b81 100644 --- a/src/ThumbnailGenerators/SmartThumbnailGenerator.php +++ b/src/ThumbnailGenerators/SmartThumbnailGenerator.php @@ -5,10 +5,18 @@ class SmartThumbnailGenerator implements IThumbnailGenerator { $tmpPath = tempnam(sys_get_temp_dir(), 'thumb') . '.jpg'; - TransferHelper::download( - $url, - $tmpPath, - null); + try + { + TransferHelper::download( + $url, + $tmpPath, + null); + } + catch (SimpleException $e) + { + echo $e->getMessage(); + return false; + } $ret = self::generateFromFile($tmpPath, $dstPath, $width, $height);