note 92438 deleted from errorfunc.configuration by googleguy
| From: | googleguy@php.net | Date: | Thu, 13 Jun 2013 11:33:38 +0000 |
| Subject: | note 92438 deleted from errorfunc.configuration by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195190@lists.php.net to get a copy of this message | ||
Note Submitter: hutchike at gmail dot com
----
If you want to avoid a fatal error when an undefined method call fails, you can add a simple
Exception thrower like this:
<?php
class MyClass
{
// ...lots of your regular code, then:
public function __call($name, $args)
{
throw new Exception('Undefined method ' . $name . '() called');
}
}
?>
This means your top-level code can simple run inside a
<?php try { call_a_method(); } catch (Exception $e) { handle_exception($e); } ?>
block, and catch the errors that were fatal before.