liip/LiipImagineBundle — pull request #531 by eXtreme (2014-11-26 07:45:56+00:00)
Title: Catch more exceptions in stream loader to throw NotLoadableException

I use Stream Loader with AWS SDK S3 stream wrapper (`s3://...`) and it does not catch S3Exception thrown by the wrapper on fopen function when the desired file does not exist on S3. The `try..catch` block captures `\Exception` only on `file_get_contents` which is too late. See the stack trace below.

```

[Aws\S3\Exception\S3Exception]
Error executing Aws\S3\S3Client::getObject() on ""; String could not be parsed as XML

Exception trace:
...
...
...
Aws\Common\AwsClient->execute() at /var/www/xxx/vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php:610
Aws\S3\StreamWrapper->openReadStream() at /var/www/xxx/vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php:125
Aws\S3\StreamWrapper->stream_open() at n/a:n/a
fopen() at /var/www/xxx/vendor/liip/imagine-bundle/Liip/ImagineBundle/Binary/Loader/StreamLoader.php:54
Liip\ImagineBundle\Binary\Loader\StreamLoader->find() at /var/www/xxx/vendor/liip/imagine-bundle/Liip/ImagineBundle/Imagine/Data/DataManager.php:118
Liip\ImagineBundle\Imagine\Data\DataManager->find() at /var/www/xxx/vendor/liip/imagine-bundle/Liip/ImagineBundle/Command/ResolveCacheCommand.php:71
Liip\ImagineBundle\Command\ResolveCacheCommand->execute() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:252
Symfony\Component\Console\Command\Command->run() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
Symfony\Component\Console\Application->doRunCommand() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /var/www/xxx/bin/console:21
```

This PR tries to address this problem by wrapping more lines in `try..catch` block in `StreamLoader::find` to trigger `NotLoadableException`, like below:

```

[Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException]
Source image s3://mybucket/test/image2.jpg not found.

Exception trace:
() at /var/www/xxx/vendor/liip/imagine-bundle/Liip/ImagineBundle/Binary/Loader/StreamLoader.php:71
Liip\ImagineBundle\Binary\Loader\StreamLoader->find() at /var/www/xxx/vendor/liip/imagine-bundle/Liip/ImagineBundle/Imagine/Data/DataManager.php:118
Liip\ImagineBundle\Imagine\Data\DataManager->find() at /var/www/xxx/vendor/liip/imagine-bundle/Liip/ImagineBundle/Command/ResolveCacheCommand.php:71
Liip\ImagineBundle\Command\ResolveCacheCommand->execute() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:252
Symfony\Component\Console\Command\Command->run() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
Symfony\Component\Console\Application->doRunCommand() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /var/www/xxx/bin/console:21
```