Error Handling: property of non-object

I’m trying to add error handling to my web app, but I’m a bit stumped on how to go about it for a simpleXML non object error.

This is the line the error occurs on.

$image = $item->ImageSets->ImageSet->SmallImage->URL;

It works 99% of the time, but some items return this line as an error. Everything I’ve tried keeps reporting the error in browser. How can I check if that code contains a non-object before the error is reported?

Thanks