note 95170 added to function.set-exception-handler
| From: | Anonymous at osu1 dot php dot net | Date: | Wed, 16 Dec 2009 14:12:36 +0000 |
| Subject: | note 95170 added to function.set-exception-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164045@lists.php.net to get a copy of this message | ||
Things you should be aware of:
An exception handler handles exceptions that were not caught before. It is the nature of an
exception that it discontinues execution of your program - since it declares an exceptional
situation in which the program cannot continue (except you catch it).
Since it has not been catched your code signals it is not being aware of the situation and cant go
on.
This implies: returning to the script is simply impossible when the exception handler has already
been called, since an uncaught exception is not a notice. use your own debug- or notice-log-system
for things like that.
Furthermore: While is is still possible to call functions from your script, since the exception
handler has already been called exceptions bubbling from that piece of code won't trigger the
exception handler again. php will die without leaving any information apart form "uncaught
exception with unknown stack frame". So if you call functions from your script, make sure that
you catch any exceptions that possibly occur via try..catch inside the exception handler.
For those of you who misinterpreted the essential meaning of the exception handler: it's only
use is to handle the abortion of your script gracefully, e.g. in a project like facebook or
wikipedia: render a nice error page, eventually hiding information which shall not leak into the
public (instead you may want to write to your log or mail the sys-admin or stuff like that).
In other words: Redirecting all php-errors form an error-handler using exceptions - including
notices - is a very dumb idea, if you do not intend having your script aborted everytime you
didn't set a variable (for example).
my 2 cents.
----
Server IP: 217.160.72.57
Probable Submitter: 85.179.8.53
----
Manual Page -- http://www.php.net/manual/en/function.set-exception-handler.php
Edit -- https://master.php.net/note/edit/95170
Del: integrated -- https://master.php.net/note/delete/95170/integrated
Del: useless -- https://master.php.net/note/delete/95170/useless
Del: bad code -- https://master.php.net/note/delete/95170/bad+code
Del: spam -- https://master.php.net/note/delete/95170/spam
Del: non-english -- https://master.php.net/note/delete/95170/non-english
Del: in docs -- https://master.php.net/note/delete/95170/in+docs
Del: other reasons-- https://master.php.net/note/delete/95170
Reject -- https://master.php.net/note/reject/95170
Search -- https://master.php.net/manage/user-notes.php