Reputation: 1682
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
Reputation: 59
Add Intervention\Image\Exception\NotReadableException
:
use Intervention\Image\Exception\NotReadableException;
try {
//
} catch(NotReadableException $e) {
//
}
Upvotes: 3
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