I have some script, that calls an error: Fatal error: Call to a member function GetData() on a non-object in ...
. I'm trying to catch this error, but it doesn't work, watch my code below:
try {
if ($data = $m->users()->GetData()) {
print_r( $data );
}
}
catch (Exception $e) {
echo 'Hey, it is an error man!';
}
How to catch it? Turning off all errors in php is impossible. I mean that sometimes I really need this error.
upd 1. Well, solution is simple:
if (is_object($m->users()) && ($data = $m->users()->GetData())) {
print_r( $data );
} else {
echo 'Hey, it is an error man!';
Thank you all!