uncaught AWS SDK S3 error 500 in Symfony2 and Twig using Liip Imagine and knp gaufrette bundles

332 views Asked by At

I have a working configuration in my Symfony2 app using Liip Imagine and knp gaufrette bundles to retrieve assets from AWS S3 using the AWS SDK version 2. This normally works fine but occasionally I get uncaught error 500 messages. These come in two forms:

Uncaught PHP Exception Aws\S3\Exception\InternalErrorException

And also

Uncaught PHP Exception Twig_Error_Runtime

caused by

Aws\\S3\\Exception\\S3Exception: 500 Internal Server Error

Please could someone tell me how to catch these errors so that the image is not rendered. I can't do this in php as I am using a third party bundle for the filter. In my twig template I just have

<img src="{{ product.path | imagine_filter('product') }}" />

The config looks like this

knp_gaufrette:
    adapters:
        amazon:
            aws_s3:
                service_id: amazonS3
                bucket_name: %s3_bucket%
                options:
                    create: true
    filesystems:
        amazonS3:
            adapter: amazon

    stream_wrapper: ~

liip_imagine:
    cache: 'amazon_s3'
    filter_sets:
        product:
            data_loader: stream.amazon
            quality: 60
            filters:
                thumbnail: { size: [194, 194], mode: inset }

Thanks

0

There are 0 answers