note 105102 added to language.exceptions
| From: | alexdowgailenko | Date: | Wed, 27 Jul 2011 19:20:23 +0000 |
| Subject: | note 105102 added to language.exceptions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181941@lists.php.net to get a copy of this message | ||
If you use the set_error_handler() to throw exceptions of errors, you may encounter issues with
__autoload() functionality saying that your class doesn't exist and that's it.
If you do this:
<?php
class MyException extends Exception
{
}
class Tester
{
public function foobar()
{
try
{
$this->helloWorld();
} catch (MyException $e) {
throw new Exception('Problem in foobar',0,$e);
}
}
protected function helloWorld()
{
throw new MyException('Problem in helloWorld()');
}
}
$tester = new Tester;
try
{
$tester->foobar();
} catch (Exception $e) {
echo $e->getTraceAsString();
}
?>
The trace will only show $tester->foobar() and not the call made to $tester->helloWorld().
In other words, if you pass a previous exception to a new one, the previous exception's stack
trace is taken into account in the new exception.
----
Server IP: 69.147.83.197
Probable Submitter: 67.22.237.2
----
Manual Page -- http://www.php.net/manual/en/language.exceptions.php
Edit -- https://master.php.net/note/edit/105102
Del: integrated -- https://master.php.net/note/delete/105102/integrated
Del: useless -- https://master.php.net/note/delete/105102/useless
Del: bad code -- https://master.php.net/note/delete/105102/bad+code
Del: spam -- https://master.php.net/note/delete/105102/spam
Del: non-english -- https://master.php.net/note/delete/105102/non-english
Del: in docs -- https://master.php.net/note/delete/105102/in+docs
Del: other reasons-- https://master.php.net/note/delete/105102
Reject -- https://master.php.net/note/reject/105102
Search -- https://master.php.net/manage/user-notes.php