I am trying to catch an error on object creation, because this object can and should sometimes throw an error.
try {
$obj = new MyObject();
} catch (Exception $e) {
echo 'Caught exception: ';
}
I want to do a lot of things with this new object, but only IF it was created without throwing an exception.
The problem is that I do not wish to do all these things inside the try catch block. How would I accomplish this?
Thanks a lot Michael
return falsein the catch block? That way if the object exists, you can keep going and don't have to keep all your code nested inside the try.If the object doesn't exist, the function that calls that code will return false.