VenomRush
VenomRush

Reputation: 1682

Laravel 5.3 Intervention/image NotReadableException using images from urls

How do I deal with the following error so that my script doesn't stop working when the exception occurs:

NotReadableException in AbstractDecoder.php line 302: Image source not readable

I've tried using the following ($file is the url of the image):

// Return false if error
try
{
    $img = Image::make($file);
}
catch(NotReadableException $e)
{
    return false;
}

This doesn't seem to catch the exception and return false. What else can I do?

Upvotes: 2

Views: 1438

Answers (2)

Codeerror
Codeerror

Reputation: 59

Add Intervention\Image\Exception\NotReadableException:

use Intervention\Image\Exception\NotReadableException;

try {
    //
} catch(NotReadableException $e) {
    //
}

Upvotes: 3

aarcarr
aarcarr

Reputation: 186

You either need the full namespaced exception in the catch area or add the use statement for that exception at the top of the file

Upvotes: 3

Related Questions